MCPcopy Create free account
hub / github.com/coreutils/coreutils / print_dir

Function print_dir

src/ls.c:2952–3114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2950 COMMAND_LINE_ARG means this directory was mentioned on the command line. */
2951
2952static void
2953print_dir (char const *name, char const *realname, bool command_line_arg)
2954{
2955 DIR *dirp;
2956 struct dirent *next;
2957 uintmax_t total_blocks = 0;
2958 static bool first = true;
2959
2960 errno = 0;
2961 dirp = opendir (name);
2962 if (!dirp)
2963 {
2964 file_failure (command_line_arg, _("cannot open directory %s"), name);
2965 return;
2966 }
2967
2968 if (LOOP_DETECT)
2969 {
2970 struct stat dir_stat;
2971 int fd = dirfd (dirp);
2972
2973 /* If dirfd failed, endure the overhead of stat'ing by path */
2974 if ((0 <= fd
2975 ? fstat_for_ino (fd, &dir_stat)
2976 : stat_for_ino (name, &dir_stat)) < 0)
2977 {
2978 file_failure (command_line_arg,
2979 _("cannot determine device and inode of %s"), name);
2980 closedir (dirp);
2981 return;
2982 }
2983
2984 /* If we've already visited this dev/inode pair, warn that
2985 we've found a loop, and do not process this directory. */
2986 if (visit_dir (dir_stat.st_dev, dir_stat.st_ino))
2987 {
2988 error (0, 0, _("%s: not listing already-listed directory"),
2989 quotef (name));
2990 closedir (dirp);
2991 set_exit_status (true);
2992 return;
2993 }
2994
2995 dev_ino_push (dir_stat.st_dev, dir_stat.st_ino);
2996 }
2997
2998 clear_files ();
2999
3000 if (recursive || print_dir_name)
3001 {
3002 if (!first)
3003 dired_outbyte ('\n');
3004 first = false;
3005 dired_indent ();
3006
3007 char *absolute_name = NULL;
3008 if (print_hyperlink)
3009 {

Callers 1

mainFunction · 0.85

Calls 15

file_failureFunction · 0.85
fstat_for_inoFunction · 0.85
stat_for_inoFunction · 0.85
visit_dirFunction · 0.85
set_exit_statusFunction · 0.85
dev_ino_pushFunction · 0.85
clear_filesFunction · 0.85
dired_outbyteFunction · 0.85
dired_indentFunction · 0.85
quote_nameFunction · 0.85
dired_outstringFunction · 0.85
file_ignoredFunction · 0.85

Tested by

no test coverage detected