summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-11-12 18:00:40 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-11-12 18:00:40 -0400
commit6f15850b2cd33486c091a6dcb7a8357ed8ff79ea (patch)
tree82f50254bc496391257785746806bf40d20c2e6f
parent003df7d397471cac6508a5ef0348547356946436 (diff)
Work around apparent bug in lsof 4.88's -F output format.
-rw-r--r--Utility/Lsof.hs14
-rw-r--r--debian/changelog1
-rw-r--r--doc/bugs/git_annex_assistant_crashes_when_parsing_lsof_output_for_version_4.88.mdwn2
-rw-r--r--doc/bugs/git_annex_assistant_crashes_when_parsing_lsof_output_for_version_4.88/comment_3_ae25d140e01d9e2a8f76b8f892ff71ec._comment42
4 files changed, 54 insertions, 5 deletions
diff --git a/Utility/Lsof.hs b/Utility/Lsof.hs
index e44d13197..ae74b25fd 100644
--- a/Utility/Lsof.hs
+++ b/Utility/Lsof.hs
@@ -93,11 +93,15 @@ parseFormatted s = bundle $ go [] $ lines s
_ -> parsefail
parsefiles c [] = (c, [])
- parsefiles c (l:ls) = case splitnull l of
- ['a':mode, 'n':file, ""] ->
- parsefiles ((file, parsemode mode):c) ls
- (('p':_):_) -> (c, l:ls)
- _ -> parsefail
+ parsefiles c (l:ls) = parsefiles' c (splitnull l) l ls
+
+ parsefiles' c ['a':mode, 'n':file, ""] _ ls =
+ parsefiles ((file, parsemode mode):c) ls
+ parsefiles' c (('p':_):_) l ls = (c, l:ls)
+ -- Some buggy versions of lsof emit a f field
+ -- that was not requested, so ignore it.
+ parsefiles' c (('f':_):rest) l ls = parsefiles' c rest l ls
+ parsefiles' _ _ _ _ = parsefail
parsemode ('r':_) = OpenReadOnly
parsemode ('w':_) = OpenWriteOnly
diff --git a/debian/changelog b/debian/changelog
index bcf47e3dd..c3fcd69b3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,7 @@ git-annex (5.20141126) UNRELEASED; urgency=medium
* proxy: New command for direct mode repositories, allows bypassing
the direct mode guard in a safe way to do all sorts of things
including git revert, git mv, git checkout ...
+ * Work around apparent bug in lsof 4.88's -F output format.
* Debian package is now maintained by Gergely Nagy.
-- Joey Hess <joeyh@debian.org> Mon, 10 Nov 2014 15:31:55 -0400
diff --git a/doc/bugs/git_annex_assistant_crashes_when_parsing_lsof_output_for_version_4.88.mdwn b/doc/bugs/git_annex_assistant_crashes_when_parsing_lsof_output_for_version_4.88.mdwn
index b914e7fc0..c374c6d57 100644
--- a/doc/bugs/git_annex_assistant_crashes_when_parsing_lsof_output_for_version_4.88.mdwn
+++ b/doc/bugs/git_annex_assistant_crashes_when_parsing_lsof_output_for_version_4.88.mdwn
@@ -1,3 +1,5 @@
lsof got updated to version 4.88 some days ago (in archlinux) and since then the assistant reports the Committer crashed while parsing lsof output.
After reverting to the previous version (4.87), it's working fine.
+
+> [[fixed|done]] --[[Joey]]
diff --git a/doc/bugs/git_annex_assistant_crashes_when_parsing_lsof_output_for_version_4.88/comment_3_ae25d140e01d9e2a8f76b8f892ff71ec._comment b/doc/bugs/git_annex_assistant_crashes_when_parsing_lsof_output_for_version_4.88/comment_3_ae25d140e01d9e2a8f76b8f892ff71ec._comment
new file mode 100644
index 000000000..b939c29bb
--- /dev/null
+++ b/doc/bugs/git_annex_assistant_crashes_when_parsing_lsof_output_for_version_4.88/comment_3_ae25d140e01d9e2a8f76b8f892ff71ec._comment
@@ -0,0 +1,42 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 3"""
+ date="2014-11-12T21:27:48Z"
+ content="""
+
+ cat > ~/tmp/dir/foo &
+ lsof -F0can +d ~/tmp/dir
+
+Old:
+
+<pre>
+p15304^@ccat^@
+aw^@n/home/joey/tmp/dir/foo^@
+</pre>
+
+New:
+
+</pre>
+p15304^@ccat^@
+f1^@aw^@n/home/joey/tmp/dir/foo^@
+p15399^@clsof^@
+f1^@aw^@npipe^@
+f4^@aw^@npipe^@
+f5^@ar^@npipe^@
+p15401^@cless^@
+f0^@ar^@npipe^@
+p15402^@clsof^@
+f3^@ar^@npipe^@
+f6^@aw^@npipe^@
+</pre>
+
+It looks like the new lsof has broken/changed -F; the file descriptor field
+is being showed even though -F0can does not request it.
+
+IMHO this is a bug in lsof.
+
+Additionally, the new lsof shows processes that have open pipes, even
+when it's been asked to show only files under a given directory.
+
+I've reported these problems upstream. Easy enough to work around in git-annex's parser.
+"""]]