File tree Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -3556,8 +3556,21 @@ print_dataset(zfs_handle_t *zhp, list_cbdata_t *cb)
3556
3556
right_justify = B_FALSE ;
3557
3557
}
3558
3558
3559
- if (pl -> pl_prop == ZFS_PROP_AVAILABLE )
3560
- color_start (zfs_list_avail_color (zhp ));
3559
+ /*
3560
+ * zfs_list_avail_color() needs ZFS_PROP_AVAILABLE + USED
3561
+ * - so we need another for() search for the USED part
3562
+ * - when no colors wanted, we can skip the whole thing
3563
+ */
3564
+ if (use_color () && pl -> pl_prop == ZFS_PROP_AVAILABLE ) {
3565
+ zprop_list_t * pl2 = cb -> cb_proplist ;
3566
+ for (; pl2 != NULL ; pl2 = pl2 -> pl_next ) {
3567
+ if (pl2 -> pl_prop == ZFS_PROP_USED ) {
3568
+ color_start (zfs_list_avail_color (zhp ));
3569
+ /* found it, no need for more loops */
3570
+ break ;
3571
+ }
3572
+ }
3573
+ }
3561
3574
3562
3575
/*
3563
3576
* If this is being called in scripted mode, or if this is the
Original file line number Diff line number Diff line change @@ -182,6 +182,7 @@ struct zfs_cmd;
182
182
#define ANSI_RESET "\033[0m"
183
183
#define ANSI_BOLD "\033[1m"
184
184
185
+ _LIBZUTIL_H int use_color (void );
185
186
_LIBZUTIL_H void color_start (const char * color );
186
187
_LIBZUTIL_H void color_end (void );
187
188
_LIBZUTIL_H int printf_color (const char * color , const char * format , ...);
Original file line number Diff line number Diff line change 259
259
<elf-symbol name='tpool_suspend' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
260
260
<elf-symbol name='tpool_suspended' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
261
261
<elf-symbol name='tpool_wait' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
262
+ <elf-symbol name='use_color' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
262
263
<elf-symbol name='update_vdev_config_dev_strs' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
263
264
<elf-symbol name='vdev_expand_proplist' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
264
265
<elf-symbol name='vdev_name_to_prop' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
5338
5339
<parameter type-id='9cf59a50'/>
5339
5340
<return type-id='48b5725f'/>
5340
5341
</function-decl>
5342
+ <function-decl name='use_color' mangled-name='use_color' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='use_color'>
5343
+ <return type-id='95e97e5e'/>
5344
+ </function-decl>
5341
5345
<function-decl name='mkdirp' mangled-name='mkdirp' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='mkdirp'>
5342
5346
<parameter type-id='80f4b756'/>
5343
5347
<parameter type-id='d50d396c'/>
Original file line number Diff line number Diff line change @@ -1965,7 +1965,7 @@ zfs_version_print(void)
1965
1965
* Return 1 if the user requested ANSI color output, and our terminal supports
1966
1966
* it. Return 0 for no color.
1967
1967
*/
1968
- static int
1968
+ int
1969
1969
use_color (void )
1970
1970
{
1971
1971
static int use_color = -1 ;
You can’t perform that action at this time.
0 commit comments