1.1 --- a/test_files/programs/ls.c Thu Apr 18 17:13:40 2024 +0200
1.2 +++ b/test_files/programs/ls.c Thu Apr 18 17:14:13 2024 +0200
1.3 @@ -22,6 +22,7 @@
1.4 * Boston, MA 02110-1301, USA
1.5 */
1.6
1.7 +#include <dirent.h>
1.8 #include <stdio.h>
1.9 #include <stdlib.h>
1.10 #include <string.h>
1.11 @@ -31,29 +32,18 @@
1.12
1.13 #include <e2access/format.h> /* get_permission_string */
1.14 #include <e2access/path.h>
1.15 +#include <fsclient/client.h>
1.16 #include <systypes/format.h>
1.17
1.18 #define FMTnlinkd "%" pFMTnlink "d"
1.19
1.20
1.21
1.22 -/* NOTE: For inclusion in the C library: stream acquisition and access. */
1.23 -
1.24 -#include <fsclient/client.h>
1.25 -#include <systypes/env.h>
1.26 -#include <systypes/fcntl.h>
1.27 -
1.28 -file_t *output;
1.29 -
1.30 -
1.31 -
1.32 /* Show object details. */
1.33
1.34 static void _show_object(const char *basename, struct stat *st)
1.35 {
1.36 - char buffer[strlen(basename) + 64];
1.37 -
1.38 - sprintf(buffer, "%s%s %5d %5d %6ld " FMTnlinkd " %s\n",
1.39 + printf("%s%s %5d %5d %6ld " FMTnlinkd " %s\n",
1.40 S_ISDIR(st->st_mode) ? "d" : "-",
1.41 get_permission_string(st->st_mode),
1.42 st->st_uid,
1.43 @@ -61,8 +51,6 @@
1.44 st->st_size,
1.45 st->st_nlink,
1.46 basename);
1.47 -
1.48 - client_write(output, buffer, strlen(buffer));
1.49 }
1.50
1.51 /* Show an object in a directory. */
1.52 @@ -97,8 +85,11 @@
1.53 {
1.54 reader = client_opendir(path);
1.55
1.56 - if (reader == NULL)
1.57 + if (!client_opened(reader))
1.58 + {
1.59 + client_close(reader);
1.60 return 1;
1.61 + }
1.62
1.63 /* Show the directory entries. */
1.64
1.65 @@ -127,8 +118,7 @@
1.66 {
1.67 /* Emit each object's name. */
1.68
1.69 - client_write(output, path, strlen(path));
1.70 - client_write(output, "\n", 1);
1.71 + printf("%s\n", path);
1.72
1.73 /* List individual files or directories. */
1.74
1.75 @@ -150,10 +140,6 @@
1.76 {
1.77 int i;
1.78
1.79 - /* NOTE: For inclusion in the C library: stream acquisition and access. */
1.80 -
1.81 - output = client_get_stream(ENV_OUTPUT_STREAM_NAME, O_WRONLY);
1.82 -
1.83 /* List the top level without any argument. */
1.84
1.85 if (argc < 2)
1.86 @@ -172,10 +158,6 @@
1.87 }
1.88 }
1.89
1.90 - /* NOTE: For inclusion in the C library: stream acquisition and access. */
1.91 -
1.92 - client_flush(output);
1.93 -
1.94 return 0;
1.95 }
1.96