unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43827: #42223 patch
@ 2020-10-06  5:23 Ruthra Kumar
  2020-10-07  3:53 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Ruthra Kumar @ 2020-10-06  5:23 UTC (permalink / raw)
  To: 43827


[-- Attachment #1.1: Type: text/plain, Size: 170 bytes --]

Severity: wishlist
Tags: patch

Bug #42223. Added support for squashfs archive files. arc-mode can now show
a dired like listing of squashfs files.

Regards
Ruthra Kumar

[-- Attachment #1.2: Type: text/html, Size: 279 bytes --]

[-- Attachment #2: 0001-Bug-42223-squashfs-mode.patch --]
[-- Type: text/x-patch, Size: 7429 bytes --]

From 95d7d5e3b70056fd572739eab3d0442d38441211 Mon Sep 17 00:00:00 2001
From: ruthra <ruthrab@gmail.com>
Date: Tue, 6 Oct 2020 10:36:26 +0530
Subject: [PATCH] Bug #42223 squashfs-mode Added support for squashfs archive
 files. Archive contents will be displayed in a dired like listing. Only read
 and extract operations are implemented as squashfs is a readonly format.

squashfs extension added to 'auto-mode-alist' and 'auto-coding-alist' variables.

Following new functions are added to 'arc-mode' major mode.
archive-squashfs-summarize
archive-squashfs-extract-by-stdout
archive-squashfs-extract
---
 lisp/arc-mode.el           | 97 ++++++++++++++++++++++++++++++++++++++
 lisp/files.el              |  4 +-
 lisp/international/mule.el |  4 +-
 3 files changed, 101 insertions(+), 4 deletions(-)

diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index c998a8a1f1..0388cfb484 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -371,6 +371,24 @@ file.  Archive and member name will be added."
 		       :inline t
 		       (string :format "%v"))))
 
+;; ------------------------------
+;; Squashfs archive configuration
+
+(defgroup archive-squashfs nil
+  "Squashfs-specific options to archive."
+  :group 'archive)
+
+(defcustom archive-squashfs-extract
+  '("rdsquashfs" "-c")
+  "Program and its options to run in order to extract a zip file member.
+Extraction should happen to standard output.  Archive and member name will
+be added."
+  :type '(list (string :tag "Program")
+	       (repeat :tag "Options"
+		       :inline t
+		       (string :format "%v")))
+  :group 'archive-squashfs)
+
 ;; -------------------------------------------------------------------------
 ;;; Section: Variables
 
@@ -742,6 +760,7 @@ archive.
                 (re-search-forward "Rar!" (+ (point) 100000) t))
            'rar-exe)
 	  ((looking-at "7z\274\257\047\034") '7z)
+          ((looking-at "hsqs") 'squashfs)
 	  (t (error "Buffer format not recognized")))))
 ;; -------------------------------------------------------------------------
 
@@ -2281,6 +2300,84 @@ NAME is expected to be the 16-bytes part of an ar record."
    descr
    '("ar" "r")))
 
+;; -------------------------------------------------------------------------
+;;; Section Squashfs archives.
+
+(defun archive-squashfs-summarize (&optional file)
+  ;; File is used internally for `archive-rar-exe-summarize'.
+  (unless file (setq file buffer-file-name))
+  (let* ((copy (file-local-copy file))
+         (maxname 10)
+         (maxusergroup 6)
+         (files ()))
+    (with-temp-buffer
+      (call-process (car archive-squashfs-extract) nil t nil "-d" (or file copy))
+      (if copy (delete-file copy))
+      (goto-char (point-min))
+      (while (looking-at (concat "^\\(file\\|dir\\) " ;File or Directory
+			         "\\(.*\\) "    ;Filename                                 
+			         "\\([0-9]+\\) "	      ;File Permission
+			         "\\([0-9]+\\) "	      ;Uid
+			         "\\([0-9]+\\)\n"	      ;Gid
+			         ))
+        (goto-char (match-end 0))
+        (let ((name (match-string 2))
+              (type (match-string 1))
+              (permission (match-string 3))
+              (uid (match-string 4))
+              (guid (match-string 5))
+              (usergroup))
+          (if (equal type "file")
+              (progn 
+                (setq usergroup (concat uid "/" guid))
+                (if (> (length name) maxname) (setq maxname (length name)))
+                (if (> (length usergroup) maxusergroup) (setq maxusergroup (length usergroup)))
+                (push (vector name name
+                              nil nil
+                              nil usergroup (archive-int-to-mode (string-to-number permission 8)))
+                      files))))))
+    (setq files (nreverse files))
+    (goto-char (point-min))
+    (let* ((format (format " %%10s %%%ds %%s" maxusergroup))
+           (sep (format format "----------" (make-string maxusergroup ?-) ""))
+           (column (length sep)))
+      (insert (format format "Filemode" "uid/gid" "Filename") "\n")
+      (insert sep (make-string maxname ?-) "\n")
+      (archive-summarize-files (mapcar (lambda (desc)
+                                         (let ((text
+                                                (format format
+                                                        (aref desc 6)  ;Filemode
+                                                        (aref desc 5) ;uid
+                                                        (aref desc 0)))) ;Filename
+                                           (vector text
+                                                   column
+                                                   (length text))))
+                                       files))
+      (insert sep (make-string maxname ?-) "\n")
+      (apply #'vector files))))
+
+(defun archive-squashfs-extract-by-stdout (archive name command &optional stderr-test)
+  (let ((stderr-file (make-temp-file "arc-stderr")))
+    (unwind-protect
+	(prog1
+	    (apply #'call-process
+		   (car command)
+		   nil
+		   (if stderr-file (list t stderr-file) t)
+		   nil
+		   (append (cdr command) (list name archive)))
+	  (with-temp-buffer
+	    (insert-file-contents stderr-file)
+	    (goto-char (point-min))
+	    (when (if (stringp stderr-test)
+		      (not (re-search-forward stderr-test nil t))
+		    (> (buffer-size) 0))
+	      (message "%s" (buffer-string)))))
+      (if (file-exists-p stderr-file)
+          (delete-file stderr-file)))))
+
+(defun archive-squashfs-extract (archive name)
+  (archive-squashfs-extract-by-stdout archive name archive-squashfs-extract))
 
 ;; -------------------------------------------------------------------------
 ;; This line was a mistake; it is kept now for compatibility.
diff --git a/lisp/files.el b/lisp/files.el
index c2c58dae93..aca62fe7eb 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2758,8 +2758,8 @@ since only a single case-insensitive search through the alist is made."
      ;; The list of archive file extensions should be in sync with
      ;; `auto-coding-alist' with `no-conversion' coding system.
      ("\\.\\(\
-arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|cbr\\|7z\\|\
-ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|CBR\\|7Z\\)\\'" . archive-mode)
+arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|cbr\\|7z\\|squashfs\\|\
+ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|CBR\\|7Z\\|SQUASHFS\\)\\'" . archive-mode)
      ("\\.oxt\\'" . archive-mode) ;(Open|Libre)Office extensions.
      ("\\.\\(deb\\|[oi]pk\\)\\'" . archive-mode) ; Debian/Opkg packages.
      ;; Mailer puts message to be edited in
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index e7496c08bf..e0d248a490 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -1710,8 +1710,8 @@ in-place."
   ;; self-extracting exe archives.
   (mapcar (lambda (arg) (cons (purecopy (car arg)) (cdr arg)))
 	  '(("\\.\\(\
-arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|7z\\|\
-ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\)\\'"
+arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|7z\\|squashfs\\|\
+ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\|SQUASHFS\\)\\'"
      . no-conversion-multibyte)
     ("\\.\\(exe\\|EXE\\)\\'" . no-conversion)
     ("\\.\\(sx[dmicw]\\|odt\\|tar\\|t[bg]z\\)\\'" . no-conversion)
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#43827: #42223 patch
  2020-10-06  5:23 bug#43827: #42223 patch Ruthra Kumar
@ 2020-10-07  3:53 ` Lars Ingebrigtsen
  2020-10-08  6:31   ` Ruthra Kumar
  0 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-07  3:53 UTC (permalink / raw)
  To: Ruthra Kumar; +Cc: 43827

Ruthra Kumar <ruthrab@gmail.com> writes:

> Bug #42223. Added support for squashfs archive files. arc-mode can now show a
> dired like listing of squashfs files.

I tried applying your patch to Emacs 28, and then opened a .snap file
(which is supposed to be a squashfs file system), but it failed with
the backtrace included below.

But it sounds like a useful addition (if the bugs can be fixed), but for
such a big addition, we'd need to have the copyright on the code
assigned to the FSF.  Would you be willing to do so?


---
Backtrace:

Debugger entered--Lisp error: (wrong-type-argument archive--file-summary [" -rw-r--r--    0/0 android.img" 19 30])
  signal(wrong-type-argument (archive--file-summary [" -rw-r--r--    0/0 android.img" 19 30]))
  archive-summarize-files(([" -rw-r--r--    0/0 android.img" 19 30] [" -rw-r--r--    0/0 apparmor/anbox-container.aa" 19 46] [" -rwxr-xr-x    0/0 bin/anbox-bridge.sh" 19 38] [" -rwxr-xr-x    0/0 bin/anbox-shell.sh" 19 37] [" -rwxr-xr-x    0/0 bin/anbox-wrapper.sh" 19 39] [" -rwxr-xr-x    0/0 bin/app-android-settings.sh" 19 46] [" -rwxr-xr-x    0/0 bin/app-appmgr.sh" 19 36] [" -rwxr-xr-x    0/0 bin/collect-bug-info.sh" 19 42] [" -rwxr-xr-x    0/0 bin/container-manager.sh" 19 43] [" -rwxr-xr-x    0/0 bin/desktop-launch" 19 37] [" -rwxr-xr-x    0/0 bin/lxc-attach" 19 33] [" -rwxr-xr-x    0/0 bin/lxc-info" 19 31] [" -rwxr-xr-x    0/0 bin/lxc-ls" 19 29] [" -rwxr-xr-x    0/0 bin/lxc-start" 19 32] [" -rwxr-xr-x    0/0 bin/lxc-stop" 19 31] [" -rwxr-xr-x    0/0 bin/lxc-top" 19 30] [" -rwxr-xr-x    0/0 command-anbox.wrapper" 19 40] [" -rwxr-xr-x    0/0 command-android-settings.wrappe..." 19 51] [" -rwxr-xr-x    0/0 command-appmgr.wrapper" 19 41] [" -rwxr-xr-x    0/0 command-collect-bug-info.wrappe..." 19 51] [" -rwxr-xr-x    0/0 command-container-manager.wrapp..." 19 52] [" -rwxr-xr-x    0/0 command-shell.wrapper" 19 40] [" -rw-r--r--    0/0 desktop/android-settings.deskto..." 19 51] [" -rw-r--r--    0/0 desktop/appmgr.desktop" 19 41] [" -rw-r--r--    0/0 etc/apparmor/parser.conf" 19 43] [" -rw-r--r--    0/0 etc/apparmor/subdomain.conf" 19 46] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/X" 19 48] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/apa..." 19 61] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/app..." 19 74] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/app..." 19 67] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/app..." 19 75] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/app..." 19 70] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/app..." 19 70] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/asp..." 19 53] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/aud..." 19 52] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/aut..." 19 61] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/bas..." 19 51] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/bas..." 19 51] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/con..." 19 55] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/cup..." 19 58] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dbu..." 19 51] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dbu..." 19 65] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dbu..." 19 72] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dbu..." 19 59] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dbu..." 19 66] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dbu..." 19 58] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dco..." 19 52] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dov..." 19 61] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/enc..." 19 54] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/fon..." 19 52] ...))
  archive-squashfs-summarize()
  archive-summarize(nil)
  archive-mode()
  set-auto-mode-0(archive-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer Nr9K6UJaIOD8wHpDEQl16nabFFt9LLEQ_185.squashfs> "~/Downloads/Nr9K6UJaIOD8wHpDEQl16nabFFt9LLEQ_185.s..." nil nil "~/Downloads/Nr9K6UJaIOD8wHpDEQl16nabFFt9LLEQ_185.s..." (24380717 66306))
  find-file-noselect("/home/larsi/Downloads/Nr9K6UJaIOD8wHpDEQl16nabFFt9..." nil nil nil)
  find-file("/home/larsi/Downloads/Nr9K6UJaIOD8wHpDEQl16nabFFt9...")
  dired-find-file()
  funcall-interactively(dired-find-file)
  call-interactively(dired-find-file nil nil)
  command-execute(dired-find-file)


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#43827: #42223 patch
  2020-10-07  3:53 ` Lars Ingebrigtsen
@ 2020-10-08  6:31   ` Ruthra Kumar
  2020-10-09  4:19     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Ruthra Kumar @ 2020-10-08  6:31 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 43827

Fixed the bug. It's now able to list and extract files from archive.

There is 1 edge case. If you press 'e' or 'RET' on a directory, the
expected behaviour is the message 'Entry is not a regular member of
archive'. Here, it tries to extract it as a file, cause
'archive-get-descr' fails to determine the type of the entry using
'mode' attribute. I face similar issues on RAR archive files as well.

I suspect the 'mode' is not an exact integer representation of file
permissions. Need more details on the 'mode' attribute of class

Currently, the 'mode' value for squashfs is calculated from the file
permissions outputted by 'unsquashfs -ll'.
Ex: "-rwxrwxr-x" -> #o775

> But it sounds like a useful addition (if the bugs can be fixed), but for
> such a big addition, we'd need to have the copyright on the code
> assigned to the FSF.  Would you be willing to do so?

Yes, i'm willing to assign copyright to Free Software Foundation. Let
me know the procedure.

diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index c998a8a1f1..4eb5a0af6e 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -371,6 +371,25 @@ archive-7z-update
                :inline t
                (string :format "%v"))))

+;; ------------------------------
+;; Squashfs archive configuration
+
+(defgroup archive-squashfs nil
+  "Squashfs-specific options to archive."
+  :group 'archive)
+
+(defcustom archive-squashfs-extract
+  '("rdsquashfs" "-c")
+  "Program and its options to run in order to extract a zip file member.
+Extraction should happen to standard output.  Archive and member name will
+be added."
+  :type '(list (string :tag "Program")
+           (repeat :tag "Options"
+               :inline t
+               (string :format "%v")))
+  :group 'archive-squashfs)
+
+
 ;; -------------------------------------------------------------------------
 ;;; Section: Variables

@@ -742,6 +761,7 @@ archive-find-type
                 (re-search-forward "Rar!" (+ (point) 100000) t))
            'rar-exe)
       ((looking-at "7z\274\257\047\034") '7z)
+          ((looking-at "hsqs") 'squashfs)
       (t (error "Buffer format not recognized")))))
 ;; -------------------------------------------------------------------------

@@ -2281,6 +2301,73 @@ archive-ar-write-file-member
    descr
    '("ar" "r")))

+;; -------------------------------------------------------------------------
+;;; Section Squashfs archives.
+
+(defun archive-squashfs-summarize (&optional file)
+  (unless file (setq file buffer-file-name))
+  (let* ((copy (file-local-copy file))
+         (files ()))
+    (with-temp-buffer
+      (call-process "unsquashfs" nil t nil "-ll" (or file copy))
+      (if copy (delete-file copy))
+      (goto-char (point-min))
+      (search-forward-regexp "[drwxl\\-]\\{10\\}")
+      (search-forward "squashfs-root" nil t nil)
+      (beginning-of-line)
+      (while
+          (looking-at (concat "^\\([drwxl\\-]\\{10\\}\\) "        ;Mode
+                              "\\(.+\\)/\\(.+\\) "  ;user/group
+                              "\\(.+\\) "     ;size
+
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\) " ;date
+                              "\\([0-9]\\{2\\}:[0-9]\\{2\\}\\) " ;time
+                              "\\(.+\\)\n"     ;Filename
+                              ))
+        (let*
+            ((name (match-string 7))
+             (flags (match-string 1))
+             (uid (match-string 2))
+             (gid (match-string 3))
+             (size (string-to-number (match-string 4)))
+             (date (match-string 5))
+             (time (match-string 6))
+             (date-time)
+             (mode))
+          (goto-char (match-end 0))
+          (if (equal name "squashfs-root")
+              (setf name "/"))
+          (setq name (string-replace "squashfs-root/" "" name))
;remove 'squashfs-root/' in filenames
+          (setq date-time (concat date " " time))
+          (setq mode (file-modes-symbolic-to-number (concat "u="
(string-replace "-" ""  (substring flags 1 4))
+                                                            ",g="
(string-replace "-" ""  (substring flags 4 7))
+                                                            ",o="
(string-replace "-" ""  (substring flags 7 10)))))  ;convert symbolic
to integer representation
+          (push (archive--file-desc name name mode size date-time
:uid uid :gid gid)
+                files))))
+    (archive--summarize-descs (nreverse files))
+    ))
+
+(defun archive-squashfs-extract-by-stdout (archive name command
&optional stderr-test)
+  (let ((stderr-file (make-temp-file "arc-stderr")))
+    (unwind-protect
+    (prog1
+        (apply #'call-process
+           (car command)
+           nil
+           (if stderr-file (list t stderr-file) t)
+           nil
+           (append (cdr command) (list name archive)))
+      (with-temp-buffer
+        (insert-file-contents stderr-file)
+        (goto-char (point-min))
+        (when (if (stringp stderr-test)
+              (not (re-search-forward stderr-test nil t))
+            (> (buffer-size) 0))
+          (message "%s" (buffer-string)))))
+      (if (file-exists-p stderr-file)
+          (delete-file stderr-file)))))
+
+(defun archive-squashfs-extract (archive name)
+  (archive-squashfs-extract-by-stdout archive name archive-squashfs-extract))

 ;; -------------------------------------------------------------------------
 ;; This line was a mistake; it is kept now for compatibility.
diff --git a/lisp/files.el b/lisp/files.el
index c2c58dae93..aca62fe7eb 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2758,8 +2758,8 @@ auto-mode-alist
      ;; The list of archive file extensions should be in sync with
      ;; `auto-coding-alist' with `no-conversion' coding system.
      ("\\.\\(\
-arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|cbr\\|7z\\|\
-ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|CBR\\|7Z\\)\\'" .
archive-mode)
+arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|cbr\\|7z\\|squashfs\\|\
+ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|CBR\\|7Z\\|SQUASHFS\\)\\'"
. archive-mode)
      ("\\.oxt\\'" . archive-mode) ;(Open|Libre)Office extensions.
      ("\\.\\(deb\\|[oi]pk\\)\\'" . archive-mode) ; Debian/Opkg packages.
      ;; Mailer puts message to be edited in
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 2af64de77b..ad9c3a2306 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -1710,8 +1710,8 @@ auto-coding-alist
   ;; self-extracting exe archives.
   (mapcar (lambda (arg) (cons (purecopy (car arg)) (cdr arg)))
       '(("\\.\\(\
-arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|7z\\|\
-ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\)\\'"
+arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|7z\\|squashfs\\|\
+ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\|SQUASHFS\\)\\'"
      . no-conversion-multibyte)
     ("\\.\\(exe\\|EXE\\)\\'" . no-conversion)
     ("\\.\\(sx[dmicw]\\|odt\\|tar\\|t[bg]z\\)\\'" . no-conversion)


On Wed, Oct 7, 2020 at 9:23 AM Lars Ingebrigtsen <larsi@gnus.org> wrote:
>
> Ruthra Kumar <ruthrab@gmail.com> writes:
>
> > Bug #42223. Added support for squashfs archive files. arc-mode can now show a
> > dired like listing of squashfs files.
>
> I tried applying your patch to Emacs 28, and then opened a .snap file
> (which is supposed to be a squashfs file system), but it failed with
> the backtrace included below.
>
> But it sounds like a useful addition (if the bugs can be fixed), but for
> such a big addition, we'd need to have the copyright on the code
> assigned to the FSF.  Would you be willing to do so?
>
>
> ---
> Backtrace:
>
> Debugger entered--Lisp error: (wrong-type-argument archive--file-summary [" -rw-r--r--    0/0 android.img" 19 30])
>   signal(wrong-type-argument (archive--file-summary [" -rw-r--r--    0/0 android.img" 19 30]))
>   archive-summarize-files(([" -rw-r--r--    0/0 android.img" 19 30] [" -rw-r--r--    0/0 apparmor/anbox-container.aa" 19 46] [" -rwxr-xr-x    0/0 bin/anbox-bridge.sh" 19 38] [" -rwxr-xr-x    0/0 bin/anbox-shell.sh" 19 37] [" -rwxr-xr-x    0/0 bin/anbox-wrapper.sh" 19 39] [" -rwxr-xr-x    0/0 bin/app-android-settings.sh" 19 46] [" -rwxr-xr-x    0/0 bin/app-appmgr.sh" 19 36] [" -rwxr-xr-x    0/0 bin/collect-bug-info.sh" 19 42] [" -rwxr-xr-x    0/0 bin/container-manager.sh" 19 43] [" -rwxr-xr-x    0/0 bin/desktop-launch" 19 37] [" -rwxr-xr-x    0/0 bin/lxc-attach" 19 33] [" -rwxr-xr-x    0/0 bin/lxc-info" 19 31] [" -rwxr-xr-x    0/0 bin/lxc-ls" 19 29] [" -rwxr-xr-x    0/0 bin/lxc-start" 19 32] [" -rwxr-xr-x    0/0 bin/lxc-stop" 19 31] [" -rwxr-xr-x    0/0 bin/lxc-top" 19 30] [" -rwxr-xr-x    0/0 command-anbox.wrapper" 19 40] [" -rwxr-xr-x    0/0 command-android-settings.wrappe..." 19 51] [" -rwxr-xr-x    0/0 command-appmgr.wrapper" 19 41] [" -rwxr-xr-x    0/0 command-collect-bug-info.wrappe..." 19 51] [" -rwxr-xr-x    0/0 command-container-manager.wrapp..." 19 52] [" -rwxr-xr-x    0/0 command-shell.wrapper" 19 40] [" -rw-r--r--    0/0 desktop/android-settings.deskto..." 19 51] [" -rw-r--r--    0/0 desktop/appmgr.desktop" 19 41] [" -rw-r--r--    0/0 etc/apparmor/parser.conf" 19 43] [" -rw-r--r--    0/0 etc/apparmor/subdomain.conf" 19 46] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/X" 19 48] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/apa..." 19 61] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/app..." 19 74] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/app..." 19 67] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/app..." 19 75] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/app..." 19 70] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/app..." 19 70] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/asp..." 19 53] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/aud..." 19 52] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/aut..." 19 61] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/bas..." 19 51] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/bas..." 19 51] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/con..." 19 55] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/cup..." 19 58] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dbu..." 19 51] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dbu..." 19 65] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dbu..." 19 72] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dbu..." 19 59] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dbu..." 19 66] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dbu..." 19 58] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dco..." 19 52] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/dov..." 19 61] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/enc..." 19 54] [" -rw-r--r--    0/0 etc/apparmor.d/abstractions/fon..." 19 52] ...))
>   archive-squashfs-summarize()
>   archive-summarize(nil)
>   archive-mode()
>   set-auto-mode-0(archive-mode nil)
>   set-auto-mode()
>   normal-mode(t)
>   after-find-file(nil t)
>   find-file-noselect-1(#<buffer Nr9K6UJaIOD8wHpDEQl16nabFFt9LLEQ_185.squashfs> "~/Downloads/Nr9K6UJaIOD8wHpDEQl16nabFFt9LLEQ_185.s..." nil nil "~/Downloads/Nr9K6UJaIOD8wHpDEQl16nabFFt9LLEQ_185.s..." (24380717 66306))
>   find-file-noselect("/home/larsi/Downloads/Nr9K6UJaIOD8wHpDEQl16nabFFt9..." nil nil nil)
>   find-file("/home/larsi/Downloads/Nr9K6UJaIOD8wHpDEQl16nabFFt9...")
>   dired-find-file()
>   funcall-interactively(dired-find-file)
>   call-interactively(dired-find-file nil nil)
>   command-execute(dired-find-file)
>
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#43827: #42223 patch
  2020-10-08  6:31   ` Ruthra Kumar
@ 2020-10-09  4:19     ` Lars Ingebrigtsen
  2020-10-09  5:25       ` Ruthra Kumar
  0 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-09  4:19 UTC (permalink / raw)
  To: Ruthra Kumar; +Cc: 43827

Ruthra Kumar <ruthrab@gmail.com> writes:

> Fixed the bug. It's now able to list and extract files from archive.

Thanks; I was unable to try it because it seems like the patch was
mangled during transport again.  Can you re-send it as an attachment?

> There is 1 edge case. If you press 'e' or 'RET' on a directory, the
> expected behaviour is the message 'Entry is not a regular member of
> archive'. Here, it tries to extract it as a file, cause
> 'archive-get-descr' fails to determine the type of the entry using
> 'mode' attribute. I face similar issues on RAR archive files as well.
>
> I suspect the 'mode' is not an exact integer representation of file
> permissions. Need more details on the 'mode' attribute of class
>
> Currently, the 'mode' value for squashfs is calculated from the file
> permissions outputted by 'unsquashfs -ll'.
> Ex: "-rwxrwxr-x" -> #o775

Right.  That should be fixed, but if the same issue is present in .rar
files, too, then doing so before integrating probably isn't necessary.

> Yes, i'm willing to assign copyright to Free Software Foundation. Let
> me know the procedure.

Sent off-list.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#43827: #42223 patch
  2020-10-09  4:19     ` Lars Ingebrigtsen
@ 2020-10-09  5:25       ` Ruthra Kumar
  2020-10-10 20:03         ` bug#43827: #42223 squashfs patch Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Ruthra Kumar @ 2020-10-09  5:25 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 43827

[-- Attachment #1: Type: text/plain, Size: 1388 bytes --]

attached latest diff.

On Fri, Oct 9, 2020 at 9:49 AM Lars Ingebrigtsen <larsi@gnus.org> wrote:
>
> Ruthra Kumar <ruthrab@gmail.com> writes:
>
> > Fixed the bug. It's now able to list and extract files from archive.
>
> Thanks; I was unable to try it because it seems like the patch was
> mangled during transport again.  Can you re-send it as an attachment?
>
> > There is 1 edge case. If you press 'e' or 'RET' on a directory, the
> > expected behaviour is the message 'Entry is not a regular member of
> > archive'. Here, it tries to extract it as a file, cause
> > 'archive-get-descr' fails to determine the type of the entry using
> > 'mode' attribute. I face similar issues on RAR archive files as well.
> >
> > I suspect the 'mode' is not an exact integer representation of file
> > permissions. Need more details on the 'mode' attribute of class
> >
> > Currently, the 'mode' value for squashfs is calculated from the file
> > permissions outputted by 'unsquashfs -ll'.
> > Ex: "-rwxrwxr-x" -> #o775
>
> Right.  That should be fixed, but if the same issue is present in .rar
> files, too, then doing so before integrating probably isn't necessary.
>
> > Yes, i'm willing to assign copyright to Free Software Foundation. Let
> > me know the procedure.
>
> Sent off-list.
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no

[-- Attachment #2: patch43827_01.diff --]
[-- Type: text/x-patch, Size: 6016 bytes --]

diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index c998a8a1f1..4eb5a0af6e 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -371,6 +371,25 @@ archive-7z-update
 		       :inline t
 		       (string :format "%v"))))
 
+;; ------------------------------
+;; Squashfs archive configuration
+
+(defgroup archive-squashfs nil
+  "Squashfs-specific options to archive."
+  :group 'archive)
+
+(defcustom archive-squashfs-extract
+  '("rdsquashfs" "-c")
+  "Program and its options to run in order to extract a zip file member.
+Extraction should happen to standard output.  Archive and member name will
+be added."
+  :type '(list (string :tag "Program")
+	       (repeat :tag "Options"
+		       :inline t
+		       (string :format "%v")))
+  :group 'archive-squashfs)
+
+
 ;; -------------------------------------------------------------------------
 ;;; Section: Variables
 
@@ -742,6 +761,7 @@ archive-find-type
                 (re-search-forward "Rar!" (+ (point) 100000) t))
            'rar-exe)
 	  ((looking-at "7z\274\257\047\034") '7z)
+          ((looking-at "hsqs") 'squashfs)          
 	  (t (error "Buffer format not recognized")))))
 ;; -------------------------------------------------------------------------
 
@@ -2281,6 +2301,73 @@ archive-ar-write-file-member
    descr
    '("ar" "r")))
 
+;; -------------------------------------------------------------------------
+;;; Section Squashfs archives.
+
+(defun archive-squashfs-summarize (&optional file)
+  (unless file (setq file buffer-file-name))
+  (let* ((copy (file-local-copy file))
+         (files ()))
+    (with-temp-buffer
+      (call-process "unsquashfs" nil t nil "-ll" (or file copy))
+      (if copy (delete-file copy))
+      (goto-char (point-min))
+      (search-forward-regexp "[drwxl\\-]\\{10\\}")
+      (search-forward "squashfs-root" nil t nil)
+      (beginning-of-line)
+      (while
+          (looking-at (concat "^\\([drwxl\\-]\\{10\\}\\) "        ;Mode
+                              "\\(.+\\)/\\(.+\\) "  ;user/group
+                              "\\(.+\\) "     ;size
+                              "\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\) " ;date
+                              "\\([0-9]\\{2\\}:[0-9]\\{2\\}\\) " ;time
+                              "\\(.+\\)\n"     ;Filename
+                              ))
+        (let*
+            ((name (match-string 7))
+             (flags (match-string 1))
+             (uid (match-string 2))
+             (gid (match-string 3))
+             (size (string-to-number (match-string 4)))
+             (date (match-string 5))
+             (time (match-string 6))
+             (date-time)
+             (mode))
+          (goto-char (match-end 0))          
+          (if (equal name "squashfs-root")
+              (setf name "/"))
+          (setq name (string-replace "squashfs-root/" "" name))  ;remove 'squashfs-root/' in filenames
+          (setq date-time (concat date " " time))
+          (setq mode (file-modes-symbolic-to-number (concat "u=" (string-replace "-" ""  (substring flags 1 4))
+                                                            ",g=" (string-replace "-" ""  (substring flags 4 7))
+                                                            ",o=" (string-replace "-" ""  (substring flags 7 10)))))  ;convert symbolic to integer representation
+          (push (archive--file-desc name name mode size date-time :uid uid :gid gid)
+                files))))
+    (archive--summarize-descs (nreverse files))
+    ))
+
+(defun archive-squashfs-extract-by-stdout (archive name command &optional stderr-test)
+  (let ((stderr-file (make-temp-file "arc-stderr")))
+    (unwind-protect
+	(prog1
+	    (apply #'call-process
+		   (car command)
+		   nil
+		   (if stderr-file (list t stderr-file) t)
+		   nil
+		   (append (cdr command) (list name archive)))
+	  (with-temp-buffer
+	    (insert-file-contents stderr-file)
+	    (goto-char (point-min))
+	    (when (if (stringp stderr-test)
+		      (not (re-search-forward stderr-test nil t))
+		    (> (buffer-size) 0))
+	      (message "%s" (buffer-string)))))
+      (if (file-exists-p stderr-file)
+          (delete-file stderr-file)))))
+
+(defun archive-squashfs-extract (archive name)
+  (archive-squashfs-extract-by-stdout archive name archive-squashfs-extract))
 
 ;; -------------------------------------------------------------------------
 ;; This line was a mistake; it is kept now for compatibility.
diff --git a/lisp/files.el b/lisp/files.el
index c2c58dae93..aca62fe7eb 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2758,8 +2758,8 @@ auto-mode-alist
      ;; The list of archive file extensions should be in sync with
      ;; `auto-coding-alist' with `no-conversion' coding system.
      ("\\.\\(\
-arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|cbr\\|7z\\|\
-ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|CBR\\|7Z\\)\\'" . archive-mode)
+arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|cbr\\|7z\\|squashfs\\|\
+ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|CBR\\|7Z\\|SQUASHFS\\)\\'" . archive-mode)
      ("\\.oxt\\'" . archive-mode) ;(Open|Libre)Office extensions.
      ("\\.\\(deb\\|[oi]pk\\)\\'" . archive-mode) ; Debian/Opkg packages.
      ;; Mailer puts message to be edited in
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 2af64de77b..ad9c3a2306 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -1710,8 +1710,8 @@ auto-coding-alist
   ;; self-extracting exe archives.
   (mapcar (lambda (arg) (cons (purecopy (car arg)) (cdr arg)))
 	  '(("\\.\\(\
-arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|7z\\|\
-ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\)\\'"
+arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|7z\\|squashfs\\|\
+ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\|SQUASHFS\\)\\'"
      . no-conversion-multibyte)
     ("\\.\\(exe\\|EXE\\)\\'" . no-conversion)
     ("\\.\\(sx[dmicw]\\|odt\\|tar\\|t[bg]z\\)\\'" . no-conversion)

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#43827: #42223 squashfs patch
  2020-10-09  5:25       ` Ruthra Kumar
@ 2020-10-10 20:03         ` Lars Ingebrigtsen
  2020-10-23  6:09           ` Ruthra Kumar
  0 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-10 20:03 UTC (permalink / raw)
  To: Ruthra Kumar; +Cc: 43827

Ruthra Kumar <ruthrab@gmail.com> writes:

> attached latest diff.

Thanks; with that version, I was able to open a .snap file (which is
squashfs) without problems.

So now we just have to wait for the FSF paperwork to happen.  After
that's completed, could you send a message to this bug report, and we'll
take it from there?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#43827: #42223 squashfs patch
  2020-10-10 20:03         ` bug#43827: #42223 squashfs patch Lars Ingebrigtsen
@ 2020-10-23  6:09           ` Ruthra Kumar
  2020-10-23 11:03             ` Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Ruthra Kumar @ 2020-10-23  6:09 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 43827

[-- Attachment #1: Type: text/plain, Size: 765 bytes --]

Hello Lars,

So, Paperwork is complete.

I've fixed the issue wherein it tries to extract a directory as a
file, added comments in required places and fixed some whitespace
warnings.

Patch is made on latest tip.

Regards
Ruthra Kumar

On Sun, Oct 11, 2020 at 1:33 AM Lars Ingebrigtsen <larsi@gnus.org> wrote:
>
> Ruthra Kumar <ruthrab@gmail.com> writes:
>
> > attached latest diff.
>
> Thanks; with that version, I was able to open a .snap file (which is
> squashfs) without problems.
>
> So now we just have to wait for the FSF paperwork to happen.  After
> that's completed, could you send a message to this bug report, and we'll
> take it from there?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no

[-- Attachment #2: 0001-Added-support-for-Squashfs-archive-files.patch --]
[-- Type: text/x-patch, Size: 7832 bytes --]

From ad63b806997cc1cabec6662093c801b0c024ea97 Mon Sep 17 00:00:00 2001
From: Ruthra Kumar <ruthrab@gmail.com>
Date: Fri, 23 Oct 2020 11:33:41 +0530
Subject: [PATCH] Added support for Squashfs archive files

---
 lisp/arc-mode.el           | 115 +++++++++++++++++++++++++++++++++----
 lisp/files.el              |   4 +-
 lisp/international/mule.el |   4 +-
 3 files changed, 108 insertions(+), 15 deletions(-)

diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index eb62a85118..c169b83c32 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -51,17 +51,17 @@
 ;; ARCHIVE TYPES: Currently only the archives below are handled, but the
 ;; structure for handling just about anything is in place.
 ;;
-;;			Arc	Lzh	Zip	Zoo	Rar	7z	Ar
-;;			--------------------------------------------------
-;; View listing		Intern	Intern	Intern	Intern	Y	Y	Y
-;; Extract member	Y	Y	Y	Y	Y	Y	Y
-;; Save changed member	Y	Y	Y	Y	N	Y	Y
-;; Add new member	N	N	N	N	N	N	N
-;; Delete member	Y	Y	Y	Y	N	Y	N
-;; Rename member	Y	Y	N	N	N	N	N
-;; Chmod		-	Y	Y	-	N	N	N
-;; Chown		-	Y	-	-	N	N	N
-;; Chgrp		-	Y	-	-	N	N	N
+;;			Arc	Lzh	Zip	Zoo	Rar	7z	Ar	Squashfs
+;;			---------------------------------------------------------------
+;; View listing		Intern	Intern	Intern	Intern	Y	Y	Y	Y
+;; Extract member	Y	Y	Y	Y	Y	Y	Y	Y
+;; Save changed member	Y	Y	Y	Y	N	Y	Y	N
+;; Add new member	N	N	N	N	N	N	N	N
+;; Delete member	Y	Y	Y	Y	N	Y	N	N
+;; Rename member	Y	Y	N	N	N	N	N	N
+;; Chmod		-	Y	Y	-	N	N	N	N
+;; Chown		-	Y	-	-	N	N	N	N
+;; Chgrp		-	Y	-	-	N	N	N	N
 ;;
 ;; Special thanks to Bill Brodie <wbrodie@panix.com> for very useful tips
 ;; on the first released version of this package.
@@ -370,6 +370,25 @@ archive-7z-update
 		       :inline t
 		       (string :format "%v"))))
 
+;; ------------------------------
+;; Squashfs archive configuration
+
+(defgroup archive-squashfs nil
+  "Squashfs-specific options to archive."
+  :group 'archive)
+
+(defcustom archive-squashfs-extract
+  '("rdsquashfs" "-c")
+  "Program and its options to run in order to extract a squashsfs file member.
+Extraction should happen to standard output.  Archive and member name will
+be added."
+  :type '(list (string :tag "Program")
+	       (repeat :tag "Options"
+		       :inline t
+		       (string :format "%v")))
+  :group 'archive-squashfs)
+
+
 ;; -------------------------------------------------------------------------
 ;;; Section: Variables
 
@@ -741,6 +760,7 @@ archive-find-type
                 (re-search-forward "Rar!" (+ (point) 100000) t))
            'rar-exe)
 	  ((looking-at "7z\274\257\047\034") '7z)
+          ((looking-at "hsqs") 'squashfs)
 	  (t (error "Buffer format not recognized")))))
 ;; -------------------------------------------------------------------------
 
@@ -2280,6 +2300,79 @@ archive-ar-write-file-member
    descr
    '("ar" "r")))
 
+;; -------------------------------------------------------------------------
+;;; Section Squashfs archives.
+
+(defun archive-squashfs-summarize (&optional file)
+  (unless file (setq file buffer-file-name))
+  (let* ((copy (file-local-copy file))
+         (files ()))
+    (with-temp-buffer
+      (call-process "unsquashfs" nil t nil "-ll" (or file copy))
+      (if copy (delete-file copy))
+      (goto-char (point-min))
+      (search-forward-regexp "[drwxl\\-]\\{10\\}")
+      (beginning-of-line)
+      (while
+          (looking-at (concat "^\\(.[rwx\\-]\\{9\\}\\) " ;Mode
+                              "\\(.+\\)/\\(.+\\) "  ;user/group
+                              "\\(.+\\) "     ;size
+                              "\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\) " ;date
+                              "\\([0-9]\\{2\\}:[0-9]\\{2\\}\\) " ;time
+                              "\\(.+\\)\n"     ;Filename
+                              ))
+        (let*
+            ((name (match-string 7))
+             (flags (match-string 1))
+             (uid (match-string 2))
+             (gid (match-string 3))
+             (size (string-to-number (match-string 4)))
+             (date (match-string 5))
+             (time (match-string 6))
+             (date-time)
+             (mode))
+          ;; Only list directory and regular files
+          (when (or  (eq (aref flags 0) ?d)
+                     (eq (aref flags 0) ?-))
+            (if (equal name "squashfs-root")
+                (setf name "/"))
+            ;; remove 'squashfs-root/' from filenames
+            (setq name (string-replace "squashfs-root/" "" name))
+            (setq date-time (concat date " " time))
+            (setq mode (logior (cond
+                                ((eq (aref flags 0) ?d) #o40000)
+                                (t 0))
+                               ;; Convert symbolic to octal representation
+                               (file-modes-symbolic-to-number (concat "u=" (string-replace "-" ""  (substring flags 1 4))
+                                                                      ",g=" (string-replace "-" ""  (substring flags 4 7))
+                                                                      ",o=" (string-replace "-" ""  (substring flags 7 10))))))
+            (push (archive--file-desc name name mode size date-time :uid uid :gid gid)
+                  files)))
+        (goto-char (match-end 0))))
+    (archive--summarize-descs (nreverse files))))
+
+(defun archive-squashfs-extract-by-stdout (archive name command &optional stderr-test)
+  (let ((stderr-file (make-temp-file "arc-stderr")))
+    (unwind-protect
+	(prog1
+	    (apply #'call-process
+		   (car command)
+		   nil
+		   (if stderr-file (list t stderr-file) t)
+		   nil
+		   (append (cdr command) (list name archive)))
+	  (with-temp-buffer
+	    (insert-file-contents stderr-file)
+	    (goto-char (point-min))
+	    (when (if (stringp stderr-test)
+		      (not (re-search-forward stderr-test nil t))
+		    (> (buffer-size) 0))
+	      (message "%s" (buffer-string)))))
+      (if (file-exists-p stderr-file)
+          (delete-file stderr-file)))))
+
+(defun archive-squashfs-extract (archive name)
+  (archive-squashfs-extract-by-stdout archive name archive-squashfs-extract))
 
 ;; -------------------------------------------------------------------------
 ;; This line was a mistake; it is kept now for compatibility.
diff --git a/lisp/files.el b/lisp/files.el
index bbc8f88159..fdf758ad92 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2758,8 +2758,8 @@ auto-mode-alist
      ;; The list of archive file extensions should be in sync with
      ;; `auto-coding-alist' with `no-conversion' coding system.
      ("\\.\\(\
-arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|cbr\\|7z\\|\
-ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|CBR\\|7Z\\)\\'" . archive-mode)
+arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|cbr\\|7z\\|squashfs\\|\
+ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|CBR\\|7Z\\|SQUASHFS\\)\\'" . archive-mode)
      ("\\.oxt\\'" . archive-mode) ;(Open|Libre)Office extensions.
      ("\\.\\(deb\\|[oi]pk\\)\\'" . archive-mode) ; Debian/Opkg packages.
      ;; Mailer puts message to be edited in
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 2af64de77b..ad9c3a2306 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -1710,8 +1710,8 @@ auto-coding-alist
   ;; self-extracting exe archives.
   (mapcar (lambda (arg) (cons (purecopy (car arg)) (cdr arg)))
 	  '(("\\.\\(\
-arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|7z\\|\
-ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\)\\'"
+arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|7z\\|squashfs\\|\
+ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\|SQUASHFS\\)\\'"
      . no-conversion-multibyte)
     ("\\.\\(exe\\|EXE\\)\\'" . no-conversion)
     ("\\.\\(sx[dmicw]\\|odt\\|tar\\|t[bg]z\\)\\'" . no-conversion)
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#43827: #42223 squashfs patch
  2020-10-23  6:09           ` Ruthra Kumar
@ 2020-10-23 11:03             ` Lars Ingebrigtsen
  0 siblings, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-23 11:03 UTC (permalink / raw)
  To: Ruthra Kumar; +Cc: 43827

Ruthra Kumar <ruthrab@gmail.com> writes:

> So, Paperwork is complete.
>
> I've fixed the issue wherein it tries to extract a directory as a
> file, added comments in required places and fixed some whitespace
> warnings.
>
> Patch is made on latest tip.

Thanks; works great.  I've now pushed this to Emacs 28 with some
whitespace changes and some change in the indentation to get the line
width down under 80 characters.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-10-23 11:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-06  5:23 bug#43827: #42223 patch Ruthra Kumar
2020-10-07  3:53 ` Lars Ingebrigtsen
2020-10-08  6:31   ` Ruthra Kumar
2020-10-09  4:19     ` Lars Ingebrigtsen
2020-10-09  5:25       ` Ruthra Kumar
2020-10-10 20:03         ` bug#43827: #42223 squashfs patch Lars Ingebrigtsen
2020-10-23  6:09           ` Ruthra Kumar
2020-10-23 11:03             ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).