Commit graph

364 commits

Author SHA1 Message Date
Yorhel
826c2fc067 Link to ncurses + some rudimentary TUI frameworky stuff
I tried playing with zbox (pure Zig termbox-like lib) for a bit, but I
don't think I want to have to deal with the terminal support issues that
will inevitably come with it. I already stumbled upon one myself: it
doesn't properly put the terminal in a sensible state after cleanup in
tmux. As much as I dislike ncurses, it /is/ ubiquitous and tends to kind
of work.
2021-05-03 08:01:18 +02:00
Yorhel
3e27d37012 Correct int truncating/saturating + avoid one toPosixPath() 2021-05-01 11:10:24 +02:00
Yorhel
097f49d9e6 Fix some scanning bugs + support --exclude-caches and --follow-symlinks
Supporting kernfs checking is going to be a bit more annoying.
And so is exclude patterns. Ugh.
2021-04-30 19:15:29 +02:00
Yorhel
e2805da076 Add CLI argument parsing 2021-04-29 18:59:25 +02:00
Yorhel
0783d35793 WIP: Experimenting with a rewrite to Zig & a new data model
The new data model is supposed to solve a few problems with ncdu 1.x's
'struct dir':
- Reduce memory overhead,
- Fix extremely slow counting of hard links in some scenarios
  (issue #121)
- Add support for counting 'shared' data with other directories
  (issue #36)

Quick memory usage comparison of my root directory with ~3.5 million
files (normal / extended mode):

  ncdu 1.15.1:     379M / 451M
  new (unaligned): 145M / 178M
  new (aligned):   155M / 200M

There's still a /lot/ of to-do's left before this is usable, however,
and there's a bunch of issues I haven't really decided on yet, such as
which TUI library to use.

Backporting this data model to the C version of ncdu is also possible,
but somewhat painful. Let's first see how far I get with Zig.
2021-04-29 12:48:52 +02:00
Yorhel
9337cdc99e Test for read error while reading the --exclude-from file
Fixes #171
2021-03-04 16:07:48 +01:00
Christian Göttsche
a216bc2d35 Scale size bar with max column size
Use 'max(10, column_size / 7)' instead of a fixed size of 10
2020-07-12 18:30:02 +02:00
Yorhel
1035aed81a Version bump for 1.15.1 2020-06-10 12:24:34 +02:00
Yorhel
a389443c9a Add --exclude-firmlinks and follow firmlinks by default
What a mess.

https://code.blicky.net/yorhel/ncdu/issues/153#issuecomment-764
2020-06-07 10:03:11 +02:00
Christian Göttsche
c340980b80 is_kernfs: Check only defined magic numbers
Avoid undeclared identifiers when compiling with older kernel headers.
2020-06-05 18:04:11 +02:00
Christian Göttsche
19cfe9b15c Correct misspellings 2020-05-30 19:26:00 +02:00
Yorhel
239bbf542f Version bump for 1.15 2020-05-30 10:02:02 +02:00
Yorhel
d018dc0be6 dir_import.c: Remove already-implemented TODO comment 2020-05-15 09:09:35 +02:00
Yorhel
1c4d191193 help.c: Mention "F" flag + make the flag list scrollable 2020-05-15 09:02:16 +02:00
Yorhel
bff5da3547 man page: Mention --follow-firmlinks 2020-05-15 08:51:08 +02:00
Yorhel
08564ec7b6 dir_scan.c: Call statfs() with relative path
So we get around the PATH_MAX limitation. Also a tiny bit more
efficient, I hope.
2020-05-15 08:43:45 +02:00
Saagar Jha
c9ce16a633 Support excluding firmlinks on macOS 2020-05-13 11:29:55 -07:00
Saagar Jha
684e9e04ad Typo: exlude → exclude 2020-05-07 16:10:07 -07:00
Yorhel
9a3727759c Fix calculating of directory apparent sizes with hard links
Silly one-character typo that causes directory apparent sizes to be very
off in some scenarios.

Reported & patched by Andrew Neitsch.
2020-05-06 07:04:36 +02:00
Yorhel
4a2def5223 dir_scan.c: Fix integer overflow when list of file names in dir exceeds 2GiB
Fixes #150
2020-04-21 14:13:51 +02:00
Yorhel
1563e56223 help.c: Mention new ^ file flag 2020-04-08 18:35:01 +02:00
Christian Göttsche
c209b012b1 Add option --exclude-kernfs to skip scanning Linux pseudo filesystems
(cherry picked from commit a076ac714a)
2020-04-08 18:32:11 +02:00
Christian Göttsche
50b48a6435 Mention supported color schemes in help text 2020-04-08 17:17:06 +02:00
Christian Göttsche
e3742f0c80 Remove redundant cast to the same type
(cherry picked from commit ef7b4e5c28)
2020-04-08 11:00:41 +02:00
Christian Göttsche
3959210051 Drop never read initialization
(cherry picked from commit 9f28920a64)
2020-04-08 10:59:25 +02:00
Christian Göttsche
84834ff370 Declare file local variables static
(cherry picked from commit ad5b7fce74)
2020-04-08 10:58:53 +02:00
Christian Göttsche
53e5080d9a Avoid using extension of variable length array folded to constant array
(cherry picked from commit 2faefc3b24)
2020-04-08 10:57:23 +02:00
Christian Göttsche
61d268764d Drop extra ';' outside of a function
(cherry picked from commit 32b77d0064)
2020-04-08 10:55:57 +02:00
Christian Göttsche
2bd83b3f22 Avoid using GNU empty initializer extension
(cherry picked from commit ce7036d249)
2020-04-08 10:55:36 +02:00
Christian Göttsche
70f439d9a9 Enforce const correctness on strings
(cherry picked from commit 9801f46ece)
2020-04-08 10:53:21 +02:00
Christian Göttsche
39709aa665 Use strict prototypes
(cherry picked from commit e4e8ebd9e0)
2020-04-08 10:52:25 +02:00
Christian Göttsche
bd22bf42ee Update configure.ac
* Use AS_HELP_STRING instead of deprecated AC_HELP_STRING
* Use AC_OUTPUT without arguments
* Enclose AC_INIT argument in brackets
* Add automake option std-options

(cherry picked from commit 53a33e1db2)
2020-04-08 10:48:14 +02:00
Christian Göttsche
227cdb35ae Ignore generated script compile in git
(cherry picked from commit fd75bd0c22)
2020-04-08 10:45:24 +02:00
Christian Göttsche
2fd4d8b406 Remove trailing whitespaces 2020-04-07 21:49:14 +02:00
Yorhel
888bd663c6 Also quit on EIO from getch()
Fixes #141
2020-04-01 16:54:57 +02:00
Yorhel
8d58297328 Year + version bump for 1.14.2 2020-02-10 16:02:26 +01:00
Yorhel
5c5cd163a1 Fix khash.h -> khashl.h reference in Makefile 2020-02-06 08:58:10 +01:00
Yorhel
2d76190091 deps/khash.h -> khashl.h for slightly reduced memory usage
Reduces memory by a tiny bit. Arguably we never needed tombstones
because entries are never removed, so there shouldn't be any performance
hit there. We don't even need a 'used' flag either, considering that can
be represented by a NULL value, but I'm not really up for
implementing/modifying my own hash table.

ref: https://attractivechaos.wordpress.com/2019/12/28/deletion-from-hash-tables-without-tombstones/
2020-02-04 19:15:48 +01:00
Yorhel
ecb71f2550 Fix definitions of global vars confirm_quit and dir_process
They were defined (rather than just declared) in .h files, when they
really should be defined in at most a single .c file.

Fixes #140.
2020-01-25 09:25:11 +01:00
Yorhel
7875a76bba static: Add AArch64 binaries 2019-12-15 10:12:13 +01:00
Yorhel
a5e08cf597 Fix cross compiler targets
I assumed that ./configure would fail if it can't find a suitable
compiler for the given --host, but it just falls back to the host gcc.

Fixes #138
2019-11-14 19:00:32 +01:00
Yorhel
62bc78d937 Increase space for item count in loading screen
Fixes #135
2019-08-17 10:35:51 +02:00
Yorhel
72189c307f Version bump for 1.14.1 + static bin improvements 2019-08-05 08:22:22 +02:00
Yorhel
dc8b6cfaab Fix --exclude-caches
Broken in 77aca35fce
Fixes #134
2019-08-04 17:31:59 +02:00
Yorhel
bb7b4196f2 Handle malloc failure by pausing any activity
This is a best-effort approach to save ncdu state when memory is low.
There's likely allocation in libraries that isn't being checked
(ncurses, printf).

Fixes #132 (it actually doesn't, that needs a 64bit static binary too,
but I'll get to that)
2019-07-23 11:03:41 +02:00
Yorhel
cd38a62aa8 Clear errno before getch()
Fixes #128.
2019-04-19 15:01:58 +02:00
Martin Storsjö
ec0de4afa8 dir_scan: Avoid allocating new copies of buf_dir
This allocation is currently leaked, but as long as we don't allocate
new ones for each refresh, that shouldn't be much of an issue.

(cherry picked from commit 9dc2d32a8f)
2019-02-19 10:05:42 +01:00
Martin Storsjö
8e021a46ee dir_setlasterr: strcpy the right variable 2019-02-18 23:50:17 +02:00
Yorhel
b6ddd491b3 Year + version bump for 1.14 2019-02-04 17:30:22 +01:00
Yorhel
882a32613d symlinks: Only call stat_to_dir() once, impove manual
stat_to_dir() assumes that buf_dir is clean; calling it twice breaks
that asumption.
2019-01-24 08:56:19 +01:00