View | Details | Raw Unified | Return to bug 189057
Collapse All | Expand All

(-)ls/ls.1 (-4 / +18 lines)
Lines 40-46 Link Here
40
.Nd list directory contents
40
.Nd list directory contents
41
.Sh SYNOPSIS
41
.Sh SYNOPSIS
42
.Nm
42
.Nm
43
.Op Fl ABCFGHILPRSTUWZabcdfghiklmnopqrstuwxy1,
43
.Op Fl ABCFGHILOPRSTUWZabcdfghiklmnopqrstuwxy1,
44
.Op Fl D Ar format
44
.Op Fl D Ar format
45
.Op Ar
45
.Op Ar
46
.Sh DESCRIPTION
46
.Sh DESCRIPTION
Lines 150-155 Link Here
150
This option cancels the
150
This option cancels the
151
.Fl P
151
.Fl P
152
option.
152
option.
153
.It Fl O
154
When used with the
155
.Fl l
156
option, display the file permissions in octal notation. Note that the file type
157
is still displayed symbolically.
153
.It Fl P
158
.It Fl P
154
If argument is a symbolic link, list the link itself rather than the
159
If argument is a symbolic link, list the link itself rather than the
155
object the link references.
160
object the link references.
Lines 526-531 Link Here
526
use
531
use
527
.Xr getfacl 1
532
.Xr getfacl 1
528
to do this.
533
to do this.
534
.Pp
535
When the
536
.Fl O
537
option is used, the entry type is displayed as described above, but the
538
permissions are displayed in
539
.Dq raw 
540
octal mode, consisting of four octal digits. The first digit indicates whether
541
any of the set-user-ID, set-group-ID or sticky bits have been set. The other
542
three digits represent the owner, group and other permissions respectively.
529
.Sh ENVIRONMENT
543
.Sh ENVIRONMENT
530
The following environment variables affect the execution of
544
The following environment variables affect the execution of
531
.Nm :
545
.Nm :
Lines 739-747 Link Here
739
.Xr getfmac 8
753
.Xr getfmac 8
740
.Sh STANDARDS
754
.Sh STANDARDS
741
With the exception of options
755
With the exception of options
742
.Fl I , g , n
756
.Fl I , g , n, o
743
and
757
and possibly
744
.Fl o ,
758
.Fl O ,
745
the
759
the
746
.Nm
760
.Nm
747
utility conforms to
761
utility conforms to
(-)ls/ls.c (-1 / +5 lines)
Lines 120-125 Link Here
120
       int f_notabs;		/* don't use tab-separated multi-col output */
120
       int f_notabs;		/* don't use tab-separated multi-col output */
121
static int f_numericonly;	/* don't convert uid/gid to name */
121
static int f_numericonly;	/* don't convert uid/gid to name */
122
       int f_octal;		/* show unprintables as \xxx */
122
       int f_octal;		/* show unprintables as \xxx */
123
       int f_octalperms;        /* print permissions and modes in octal */
123
       int f_octal_escape;	/* like f_octal but use C escapes if possible */
124
       int f_octal_escape;	/* like f_octal but use C escapes if possible */
124
static int f_recursive;		/* ls subdirectories also */
125
static int f_recursive;		/* ls subdirectories also */
125
static int f_reversesort;	/* reverse whatever sort is used */
126
static int f_reversesort;	/* reverse whatever sort is used */
Lines 186-192 Link Here
186
	if (getenv("LS_SAMESORT"))
187
	if (getenv("LS_SAMESORT"))
187
		f_samesort = 1;
188
		f_samesort = 1;
188
	while ((ch = getopt(argc, argv,
189
	while ((ch = getopt(argc, argv,
189
	    "1ABCD:FGHILPRSTUWXZabcdfghiklmnopqrstuwxy,")) != -1) {
190
	    "1ABCD:FGHILOPRSTUWXZabcdfghiklmnopqrstuwxy,")) != -1) {
190
		switch (ch) {
191
		switch (ch) {
191
		/*
192
		/*
192
		 * The -1, -C, -x and -l options all override each other so
193
		 * The -1, -C, -x and -l options all override each other so
Lines 272-277 Link Here
272
			fts_options |= FTS_LOGICAL;
273
			fts_options |= FTS_LOGICAL;
273
			f_nofollow = 0;
274
			f_nofollow = 0;
274
			break;
275
			break;
276
		case 'O':
277
			f_octalperms=1;
278
			break;
275
		case 'P':
279
		case 'P':
276
			fts_options &= ~FTS_COMFOLLOW;
280
			fts_options &= ~FTS_COMFOLLOW;
277
			fts_options &= ~FTS_LOGICAL;
281
			fts_options &= ~FTS_LOGICAL;
(-)ls/ls.h (+1 lines)
Lines 47-52 Link Here
47
extern int f_inode;		/* print inode */
47
extern int f_inode;		/* print inode */
48
extern int f_longform;		/* long listing format */
48
extern int f_longform;		/* long listing format */
49
extern int f_octal;		/* print unprintables in octal */
49
extern int f_octal;		/* print unprintables in octal */
50
extern int f_octalperms;        /* print permissions and modes in octal */
50
extern int f_octal_escape;	/* like f_octal but use C escapes if possible */
51
extern int f_octal_escape;	/* like f_octal but use C escapes if possible */
51
extern int f_nonprint;		/* show unprintables as ? */
52
extern int f_nonprint;		/* show unprintables as ? */
52
extern int f_samesort;		/* sort time and name in same direction */
53
extern int f_samesort;		/* sort time and name in same direction */
(-)ls/print.c (-1 / +46 lines)
Lines 73-78 Link Here
73
static int	colortype(mode_t);
73
static int	colortype(mode_t);
74
#endif
74
#endif
75
static void	aclmode(char *, const FTSENT *);
75
static void	aclmode(char *, const FTSENT *);
76
static void     octalmode(int, char *);
76
77
77
#define	IS_NOPRINT(p)	((p)->fts_number == NO_PRINT)
78
#define	IS_NOPRINT(p)	((p)->fts_number == NO_PRINT)
78
79
Lines 141-152 Link Here
141
#ifdef COLORLS
142
#ifdef COLORLS
142
	int color_printed = 0;
143
	int color_printed = 0;
143
#endif
144
#endif
145
	void (*strmodefcn)(int, char *);
144
146
145
	if ((dp->list == NULL || dp->list->fts_level != FTS_ROOTLEVEL) &&
147
	if ((dp->list == NULL || dp->list->fts_level != FTS_ROOTLEVEL) &&
146
	    (f_longform || f_size)) {
148
	    (f_longform || f_size)) {
147
		(void)printf("total %lu\n", howmany(dp->btotal, blocksize));
149
		(void)printf("total %lu\n", howmany(dp->btotal, blocksize));
148
	}
150
	}
149
151
152
	strmodefcn = (f_octalperms > 0) ? octalmode : strmode;
153
150
	for (p = dp->list; p; p = p->fts_link) {
154
	for (p = dp->list; p; p = p->fts_link) {
151
		if (IS_NOPRINT(p))
155
		if (IS_NOPRINT(p))
152
			continue;
156
			continue;
Lines 157-163 Link Here
157
		if (f_size)
161
		if (f_size)
158
			(void)printf("%*jd ",
162
			(void)printf("%*jd ",
159
			    dp->s_block, howmany(sp->st_blocks, blocksize));
163
			    dp->s_block, howmany(sp->st_blocks, blocksize));
160
		strmode(sp->st_mode, buf);
164
		strmodefcn(sp->st_mode, buf);
161
		aclmode(buf, p);
165
		aclmode(buf, p);
162
		np = p->fts_pointer;
166
		np = p->fts_pointer;
163
		(void)printf("%s %*u %-*s  %-*s  ", buf, dp->s_nlink,
167
		(void)printf("%s %*u %-*s  %-*s  ", buf, dp->s_nlink,
Lines 684-686 Link Here
684
		buf[10] = '+';
688
		buf[10] = '+';
685
	acl_free(facl);
689
	acl_free(facl);
686
}
690
}
691
692
/*
693
 * Print file mode and permissions in octal mode. Like the regular strmode(),
694
 * add a space at the end for (potential) use by aclmode().
695
 */
696
static void
697
octalmode(int mode, char *bp)
698
{
699
        /* Print the file type symbolically, this makes no sense in octal. */
700
	switch (mode & S_IFMT) {
701
	case S_IFDIR:
702
		*bp++ = 'd';
703
		break;
704
	case S_IFCHR:
705
		*bp++ = 'c';
706
		break;
707
	case S_IFBLK:
708
		*bp++ = 'b';
709
		break;
710
	case S_IFREG:
711
		*bp++ = '-';
712
		break;
713
	case S_IFLNK:
714
		*bp++ = 'l';
715
		break;
716
	case S_IFSOCK:
717
		*bp++ = 's';
718
		break;
719
	case S_IFIFO:
720
		*bp++ = 'p';
721
		break;
722
	case S_IFWHT:
723
		*bp++ = 'w';
724
		break;
725
	default:
726
		*bp++ = '?';
727
		break;
728
	}
729
	(void)snprintf(bp, 6, "%o%o%o%o ", (mode & 0007000) >> 9,
730
	    (mode & S_IRWXU) >> 6, (mode & S_IRWXG) >> 3, mode & S_IRWXO);
731
}
(-)ls/util.c (-2 / +2 lines)
Lines 222-230 Link Here
222
{
222
{
223
	(void)fprintf(stderr,
223
	(void)fprintf(stderr,
224
#ifdef COLORLS
224
#ifdef COLORLS
225
	"usage: ls [-ABCFGHILPRSTUWZabcdfghiklmnopqrstuwxy1,] [-D format]"
225
	"usage: ls [-ABCFGHILOPRSTUWZabcdfghiklmnopqrstuwxy1,] [-D format]"
226
#else
226
#else
227
	"usage: ls [-ABCFHILPRSTUWZabcdfghiklmnopqrstuwxy1,] [-D format]"
227
	"usage: ls [-ABCFHILOPRSTUWZabcdfghiklmnopqrstuwxy1,] [-D format]"
228
#endif
228
#endif
229
		      " [file ...]\n");
229
		      " [file ...]\n");
230
	exit(1);
230
	exit(1);

Return to bug 189057