1.1 --- a/tests/dstest_block_client_simple.cc Thu Jan 27 23:45:17 2022 +0100
1.2 +++ b/tests/dstest_block_client_simple.cc Sun Feb 06 18:05:23 2022 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Test dataspace operations.
1.6 *
1.7 - * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -33,36 +33,17 @@
1.13 {
1.14 if (argc < 2)
1.15 {
1.16 - printf("Need a filename, optional user identifier, and optional repetition.\n");
1.17 + printf("Need a filename and optional repetition.\n");
1.18 return 1;
1.19 }
1.20
1.21 /* Obtain filename and access parameters. */
1.22
1.23 char *filename = argv[1];
1.24 - bool have_uid = (argc > 2) && strlen(argv[2]);
1.25 - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0;
1.26 - int repetition = argc > 3 ? atoi(argv[3]) : 10;
1.27 + int repetition = argc > 2 ? atoi(argv[2]) : 10;
1.28 file_t *file;
1.29
1.30 - /* With a user, open a user-specific file opener. */
1.31 -
1.32 - if (have_uid)
1.33 - {
1.34 - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022});
1.35 -
1.36 - if (l4_is_invalid_cap(opener))
1.37 - {
1.38 - printf("Could not obtain opener for file.\n");
1.39 - return 1;
1.40 - }
1.41 -
1.42 - /* Invoke the open method to receive the file reference. */
1.43 -
1.44 - file = client_open_using(filename, O_RDWR, opener);
1.45 - }
1.46 - else
1.47 - file = client_open(filename, O_RDWR);
1.48 + file = client_open(filename, O_RDWR);
1.49
1.50 if (file == NULL)
1.51 {
2.1 --- a/tests/dstest_file_client.cc Thu Jan 27 23:45:17 2022 +0100
2.2 +++ b/tests/dstest_file_client.cc Sun Feb 06 18:05:23 2022 +0100
2.3 @@ -1,7 +1,7 @@
2.4 /*
2.5 * Test file operations.
2.6 *
2.7 - * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
2.8 + * Copyright (C) 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
2.9 *
2.10 * This program is free software; you can redistribute it and/or
2.11 * modify it under the terms of the GNU General Public License as
2.12 @@ -137,37 +137,15 @@
2.13 {
2.14 if (argc < 2)
2.15 {
2.16 - printf("Need a filename and an optional user identifier (if used with a filesystem).\n");
2.17 + printf("Need a filename.\n");
2.18 return 1;
2.19 }
2.20
2.21 char *filename = argv[1];
2.22 - bool have_uid = (argc > 2) && strlen(argv[2]);
2.23 - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0;
2.24 file_t *file1, *file2;
2.25
2.26 - /* With a user, open a user-specific file opener. */
2.27 -
2.28 - if (have_uid)
2.29 - {
2.30 - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022});
2.31 -
2.32 - if (l4_is_invalid_cap(opener))
2.33 - {
2.34 - printf("Could not obtain opener for file.\n");
2.35 - return 1;
2.36 - }
2.37 -
2.38 - /* Invoke the open method to receive the file reference. */
2.39 -
2.40 - file1 = client_open_using(filename, O_RDWR | O_CREAT, opener);
2.41 - file2 = client_open_using(filename, O_RDWR, opener);
2.42 - }
2.43 - else
2.44 - {
2.45 - file1 = client_open(filename, O_RDWR | O_CREAT);
2.46 - file2 = client_open(filename, O_RDWR);
2.47 - }
2.48 + file1 = client_open(filename, O_RDWR | O_CREAT);
2.49 + file2 = client_open(filename, O_RDWR);
2.50
2.51 if ((file1 == NULL) || (file2 == NULL))
2.52 {
3.1 --- a/tests/dstest_file_monitor.cc Thu Jan 27 23:45:17 2022 +0100
3.2 +++ b/tests/dstest_file_monitor.cc Sun Feb 06 18:05:23 2022 +0100
3.3 @@ -1,7 +1,7 @@
3.4 /*
3.5 * Test directory monitoring operations.
3.6 *
3.7 - * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
3.8 + * Copyright (C) 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
3.9 *
3.10 * This program is free software; you can redistribute it and/or
3.11 * modify it under the terms of the GNU General Public License as
3.12 @@ -34,35 +34,9 @@
3.13
3.14
3.15
3.16 -static file_t *open_object(char *filename, flags_t flags, bool have_uid, sys_uid_t uid)
3.17 -{
3.18 - /* With a user, open a user-specific file opener. */
3.19 -
3.20 - if (have_uid)
3.21 - {
3.22 - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022});
3.23 -
3.24 - if (l4_is_invalid_cap(opener))
3.25 - {
3.26 - printf("Could not obtain opener for file.\n");
3.27 - return NULL;
3.28 - }
3.29 -
3.30 - /* Invoke the open method to receive the reference. */
3.31 -
3.32 - return client_open_using(filename, flags, opener);
3.33 - }
3.34 - else
3.35 - {
3.36 - return client_open(filename, flags);
3.37 - }
3.38 -}
3.39 -
3.40 -
3.41 -
3.42 /* Open files in the directory given by filename. */
3.43
3.44 -static void open_files(const char *filename, bool have_uid, sys_uid_t uid)
3.45 +static void open_files(const char *filename)
3.46 {
3.47 char *buffer = (char *) calloc(strlen(filename) + 10, sizeof(char));
3.48
3.49 @@ -76,7 +50,7 @@
3.50 {
3.51 sprintf(buffer, "%s/file%02d", filename, i);
3.52
3.53 - open_object(buffer, O_CREAT | O_RDWR, have_uid, uid);
3.54 + client_open(buffer, O_CREAT | O_RDWR);
3.55 sleep(1);
3.56 }
3.57 }
3.58 @@ -115,17 +89,15 @@
3.59 {
3.60 if (argc < 2)
3.61 {
3.62 - printf("Need a directory name and an optional user identifier (if used with a filesystem).\n");
3.63 + printf("Need a directory name.\n");
3.64 return 1;
3.65 }
3.66
3.67 char *filename = argv[1];
3.68 - bool have_uid = (argc > 2) && strlen(argv[2]);
3.69 - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0;
3.70
3.71 printf("Opening %s...\n", filename);
3.72
3.73 - file_t *directory = open_object(filename, O_DIRECTORY, have_uid, uid);
3.74 + file_t *directory = client_open(filename, O_DIRECTORY);
3.75
3.76 if (directory == NULL)
3.77 {
3.78 @@ -137,7 +109,7 @@
3.79
3.80 std::thread *activities[2];
3.81
3.82 - activities[0] = new std::thread(open_files, filename, have_uid, uid);
3.83 + activities[0] = new std::thread(open_files, filename);
3.84 activities[1] = new std::thread(monitor_files, directory);
3.85
3.86 for (int i = 0; i < 2; i++)
4.1 --- a/tests/dstest_file_readdir.cc Thu Jan 27 23:45:17 2022 +0100
4.2 +++ b/tests/dstest_file_readdir.cc Sun Feb 06 18:05:23 2022 +0100
4.3 @@ -1,7 +1,7 @@
4.4 /*
4.5 * Test directory reading operations.
4.6 *
4.7 - * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
4.8 + * Copyright (C) 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
4.9 *
4.10 * This program is free software; you can redistribute it and/or
4.11 * modify it under the terms of the GNU General Public License as
4.12 @@ -31,47 +31,19 @@
4.13
4.14
4.15
4.16 -static file_t *open_directory(char *filename, bool have_uid, sys_uid_t uid)
4.17 -{
4.18 - /* With a user, open a user-specific file opener. */
4.19 -
4.20 - if (have_uid)
4.21 - {
4.22 - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022});
4.23 -
4.24 - if (l4_is_invalid_cap(opener))
4.25 - {
4.26 - printf("Could not obtain opener for file.\n");
4.27 - return NULL;
4.28 - }
4.29 -
4.30 - /* Invoke the open method to receive the file reference. */
4.31 -
4.32 - return client_opendir_using(filename, opener);
4.33 - }
4.34 - else
4.35 - {
4.36 - return client_opendir(filename);
4.37 - }
4.38 -}
4.39 -
4.40 -
4.41 -
4.42 int main(int argc, char *argv[])
4.43 {
4.44 if (argc < 2)
4.45 {
4.46 - printf("Need a directory name and an optional user identifier (if used with a filesystem).\n");
4.47 + printf("Need a directory name.\n");
4.48 return 1;
4.49 }
4.50
4.51 char *filename = argv[1];
4.52 - bool have_uid = (argc > 2) && strlen(argv[2]);
4.53 - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0;
4.54
4.55 printf("Opening %s...\n", filename);
4.56
4.57 - file_t *reader = open_directory(filename, have_uid, uid);
4.58 + file_t *reader = client_opendir(filename);
4.59
4.60 if (reader == NULL)
4.61 {
4.62 @@ -93,7 +65,7 @@
4.63
4.64 /* Open again, reading a single entry only. */
4.65
4.66 - reader = open_directory(filename, have_uid, uid);
4.67 + reader = client_opendir(filename);
4.68
4.69 if (reader == NULL)
4.70 {
5.1 --- a/tests/dstest_file_readdir_concurrent.cc Thu Jan 27 23:45:17 2022 +0100
5.2 +++ b/tests/dstest_file_readdir_concurrent.cc Sun Feb 06 18:05:23 2022 +0100
5.3 @@ -1,7 +1,7 @@
5.4 /*
5.5 * Test directory reading operations, exploring concurrency issues.
5.6 *
5.7 - * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
5.8 + * Copyright (C) 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
5.9 *
5.10 * This program is free software; you can redistribute it and/or
5.11 * modify it under the terms of the GNU General Public License as
5.12 @@ -31,95 +31,19 @@
5.13
5.14
5.15
5.16 -static file_t *open_directory(char *filename, bool have_uid, sys_uid_t uid)
5.17 -{
5.18 - /* With a user, open a user-specific file opener. */
5.19 -
5.20 - if (have_uid)
5.21 - {
5.22 - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022});
5.23 -
5.24 - if (l4_is_invalid_cap(opener))
5.25 - {
5.26 - printf("Could not obtain opener for file.\n");
5.27 - return NULL;
5.28 - }
5.29 -
5.30 - /* Invoke the open method to receive the file reference. */
5.31 -
5.32 - return client_opendir_using(filename, opener);
5.33 - }
5.34 - else
5.35 - {
5.36 - return client_opendir(filename);
5.37 - }
5.38 -}
5.39 -
5.40 -static file_t *open_file(char *filename, bool have_uid, sys_uid_t uid)
5.41 -{
5.42 - /* With a user, open a user-specific file opener. */
5.43 -
5.44 - if (have_uid)
5.45 - {
5.46 - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022});
5.47 -
5.48 - if (l4_is_invalid_cap(opener))
5.49 - {
5.50 - printf("Could not obtain opener for file.\n");
5.51 - return NULL;
5.52 - }
5.53 -
5.54 - /* Invoke the open method to receive the file reference. */
5.55 -
5.56 - return client_open_using(filename, O_RDWR | O_CREAT, opener);
5.57 - }
5.58 - else
5.59 - {
5.60 - return client_open(filename, O_RDWR | O_CREAT);
5.61 - }
5.62 -}
5.63 -
5.64 -static long remove_file(char *filename, bool have_uid, sys_uid_t uid)
5.65 -{
5.66 - /* With a user, open a user-specific file opener. */
5.67 -
5.68 - if (have_uid)
5.69 - {
5.70 - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022});
5.71 -
5.72 - if (l4_is_invalid_cap(opener))
5.73 - {
5.74 - printf("Could not obtain opener for file.\n");
5.75 - return -L4_EIO;
5.76 - }
5.77 -
5.78 - /* Invoke the remove method to remove the file. */
5.79 -
5.80 - return client_remove_using(filename, opener);
5.81 - }
5.82 - else
5.83 - {
5.84 - return client_remove(filename);
5.85 - }
5.86 -}
5.87 -
5.88 -
5.89 -
5.90 int main(int argc, char *argv[])
5.91 {
5.92 if (argc < 2)
5.93 {
5.94 - printf("Need a directory name and an optional user identifier (if used with a filesystem).\n");
5.95 + printf("Need a directory name.\n");
5.96 return 1;
5.97 }
5.98
5.99 char *filename = argv[1];
5.100 - bool have_uid = (argc > 2) && strlen(argv[2]);
5.101 - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0;
5.102
5.103 printf("Opening %s...\n", filename);
5.104
5.105 - file_t *reader = open_directory(filename, have_uid, uid);
5.106 + file_t *reader = client_opendir(filename);
5.107
5.108 if (reader == NULL)
5.109 {
5.110 @@ -147,7 +71,7 @@
5.111 {
5.112 sprintf(buffer, "%s/file-%d.txt", filename, filenum++);
5.113
5.114 - file_t *file = open_file(buffer, have_uid, uid);
5.115 + file_t *file = client_open(buffer, O_RDWR | O_CREAT);
5.116
5.117 if (file == NULL)
5.118 {
5.119 @@ -172,7 +96,7 @@
5.120
5.121 /* Re-read, counting files. */
5.122
5.123 - reader = open_directory(filename, have_uid, uid);
5.124 + reader = client_opendir(filename);
5.125
5.126 if (reader == NULL)
5.127 {
5.128 @@ -196,7 +120,7 @@
5.129 {
5.130 sprintf(buffer, "%s/file-%d.txt", filename, filenum++);
5.131
5.132 - long err = remove_file(buffer, have_uid, uid);
5.133 + long err = client_remove(buffer);
5.134
5.135 if (err)
5.136 {
5.137 @@ -207,7 +131,7 @@
5.138
5.139 /* Re-read, counting files. */
5.140
5.141 - reader = open_directory(filename, have_uid, uid);
5.142 + reader = client_opendir(filename);
5.143
5.144 if (reader == NULL)
5.145 {
6.1 --- a/tests/dstest_file_rename.cc Thu Jan 27 23:45:17 2022 +0100
6.2 +++ b/tests/dstest_file_rename.cc Sun Feb 06 18:05:23 2022 +0100
6.3 @@ -31,71 +31,19 @@
6.4
6.5
6.6
6.7 -static file_t *open_directory(char *filename, bool have_uid, sys_uid_t uid)
6.8 -{
6.9 - /* With a user, open a user-specific file opener. */
6.10 -
6.11 - if (have_uid)
6.12 - {
6.13 - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022});
6.14 -
6.15 - if (l4_is_invalid_cap(opener))
6.16 - {
6.17 - printf("Could not obtain opener for file.\n");
6.18 - return NULL;
6.19 - }
6.20 -
6.21 - /* Invoke the open method to receive the file reference. */
6.22 -
6.23 - return client_opendir_using(filename, opener);
6.24 - }
6.25 - else
6.26 - {
6.27 - return client_opendir(filename);
6.28 - }
6.29 -}
6.30 -
6.31 -static long rename_file(char *source, char *target, bool have_uid, sys_uid_t uid)
6.32 -{
6.33 - /* With a user, open a user-specific file opener. */
6.34 -
6.35 - if (have_uid)
6.36 - {
6.37 - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022});
6.38 -
6.39 - if (l4_is_invalid_cap(opener))
6.40 - {
6.41 - printf("Could not obtain opener for file.\n");
6.42 - return -L4_EIO;
6.43 - }
6.44 -
6.45 - /* Invoke the rename method to rename the file. */
6.46 -
6.47 - return client_rename_using(source, target, opener);
6.48 - }
6.49 - else
6.50 - {
6.51 - return client_rename(source, target);
6.52 - }
6.53 -}
6.54 -
6.55 -
6.56 -
6.57 int main(int argc, char *argv[])
6.58 {
6.59 if (argc < 2)
6.60 {
6.61 - printf("Need a directory name and an optional user identifier (if used with a filesystem).\n");
6.62 + printf("Need a directory name.\n");
6.63 return 1;
6.64 }
6.65
6.66 char *filename = argv[1];
6.67 - bool have_uid = (argc > 2) && strlen(argv[2]);
6.68 - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0;
6.69
6.70 printf("Opening %s...\n", filename);
6.71
6.72 - file_t *reader = open_directory(filename, have_uid, uid);
6.73 + file_t *reader = client_opendir(filename);
6.74
6.75 if (reader == NULL)
6.76 {
6.77 @@ -126,7 +74,7 @@
6.78 sprintf(source, "%s/file-%d.txt", filename, filenum);
6.79 sprintf(target, "%s/renamed-%d.txt", filename, filenum);
6.80
6.81 - long err = rename_file(source, target, have_uid, uid);
6.82 + long err = client_rename(source, target);
6.83
6.84 if (err)
6.85 {
6.86 @@ -137,7 +85,7 @@
6.87
6.88 /* Show the new listing. */
6.89
6.90 - reader = open_directory(filename, have_uid, uid);
6.91 + reader = client_opendir(filename);
6.92
6.93 if (reader == NULL)
6.94 {