# HG changeset patch # User Paul Boddie # Date 1644167123 -3600 # Node ID 2582a68006ff80067dfa7649884ca65856a8ba4d # Parent b769dcb3f4b339953ad34ca48c42e8e22d4f0e1e Removed support for indicating the user identifier in the test programs. Each test configuration should obtain an appropriate opener object and present this to the test program. diff -r b769dcb3f4b3 -r 2582a68006ff tests/dstest_block_client_simple.cc --- a/tests/dstest_block_client_simple.cc Thu Jan 27 23:45:17 2022 +0100 +++ b/tests/dstest_block_client_simple.cc Sun Feb 06 18:05:23 2022 +0100 @@ -1,7 +1,7 @@ /* * Test dataspace operations. * - * Copyright (C) 2020, 2021 Paul Boddie + * Copyright (C) 2020, 2021, 2022 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -33,36 +33,17 @@ { if (argc < 2) { - printf("Need a filename, optional user identifier, and optional repetition.\n"); + printf("Need a filename and optional repetition.\n"); return 1; } /* Obtain filename and access parameters. */ char *filename = argv[1]; - bool have_uid = (argc > 2) && strlen(argv[2]); - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0; - int repetition = argc > 3 ? atoi(argv[3]) : 10; + int repetition = argc > 2 ? atoi(argv[2]) : 10; file_t *file; - /* With a user, open a user-specific file opener. */ - - if (have_uid) - { - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022}); - - if (l4_is_invalid_cap(opener)) - { - printf("Could not obtain opener for file.\n"); - return 1; - } - - /* Invoke the open method to receive the file reference. */ - - file = client_open_using(filename, O_RDWR, opener); - } - else - file = client_open(filename, O_RDWR); + file = client_open(filename, O_RDWR); if (file == NULL) { diff -r b769dcb3f4b3 -r 2582a68006ff tests/dstest_file_client.cc --- a/tests/dstest_file_client.cc Thu Jan 27 23:45:17 2022 +0100 +++ b/tests/dstest_file_client.cc Sun Feb 06 18:05:23 2022 +0100 @@ -1,7 +1,7 @@ /* * Test file operations. * - * Copyright (C) 2020, 2021 Paul Boddie + * Copyright (C) 2020, 2021, 2022 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -137,37 +137,15 @@ { if (argc < 2) { - printf("Need a filename and an optional user identifier (if used with a filesystem).\n"); + printf("Need a filename.\n"); return 1; } char *filename = argv[1]; - bool have_uid = (argc > 2) && strlen(argv[2]); - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0; file_t *file1, *file2; - /* With a user, open a user-specific file opener. */ - - if (have_uid) - { - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022}); - - if (l4_is_invalid_cap(opener)) - { - printf("Could not obtain opener for file.\n"); - return 1; - } - - /* Invoke the open method to receive the file reference. */ - - file1 = client_open_using(filename, O_RDWR | O_CREAT, opener); - file2 = client_open_using(filename, O_RDWR, opener); - } - else - { - file1 = client_open(filename, O_RDWR | O_CREAT); - file2 = client_open(filename, O_RDWR); - } + file1 = client_open(filename, O_RDWR | O_CREAT); + file2 = client_open(filename, O_RDWR); if ((file1 == NULL) || (file2 == NULL)) { diff -r b769dcb3f4b3 -r 2582a68006ff tests/dstest_file_monitor.cc --- a/tests/dstest_file_monitor.cc Thu Jan 27 23:45:17 2022 +0100 +++ b/tests/dstest_file_monitor.cc Sun Feb 06 18:05:23 2022 +0100 @@ -1,7 +1,7 @@ /* * Test directory monitoring operations. * - * Copyright (C) 2020, 2021 Paul Boddie + * Copyright (C) 2020, 2021, 2022 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -34,35 +34,9 @@ -static file_t *open_object(char *filename, flags_t flags, bool have_uid, sys_uid_t uid) -{ - /* With a user, open a user-specific file opener. */ - - if (have_uid) - { - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022}); - - if (l4_is_invalid_cap(opener)) - { - printf("Could not obtain opener for file.\n"); - return NULL; - } - - /* Invoke the open method to receive the reference. */ - - return client_open_using(filename, flags, opener); - } - else - { - return client_open(filename, flags); - } -} - - - /* Open files in the directory given by filename. */ -static void open_files(const char *filename, bool have_uid, sys_uid_t uid) +static void open_files(const char *filename) { char *buffer = (char *) calloc(strlen(filename) + 10, sizeof(char)); @@ -76,7 +50,7 @@ { sprintf(buffer, "%s/file%02d", filename, i); - open_object(buffer, O_CREAT | O_RDWR, have_uid, uid); + client_open(buffer, O_CREAT | O_RDWR); sleep(1); } } @@ -115,17 +89,15 @@ { if (argc < 2) { - printf("Need a directory name and an optional user identifier (if used with a filesystem).\n"); + printf("Need a directory name.\n"); return 1; } char *filename = argv[1]; - bool have_uid = (argc > 2) && strlen(argv[2]); - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0; printf("Opening %s...\n", filename); - file_t *directory = open_object(filename, O_DIRECTORY, have_uid, uid); + file_t *directory = client_open(filename, O_DIRECTORY); if (directory == NULL) { @@ -137,7 +109,7 @@ std::thread *activities[2]; - activities[0] = new std::thread(open_files, filename, have_uid, uid); + activities[0] = new std::thread(open_files, filename); activities[1] = new std::thread(monitor_files, directory); for (int i = 0; i < 2; i++) diff -r b769dcb3f4b3 -r 2582a68006ff tests/dstest_file_readdir.cc --- a/tests/dstest_file_readdir.cc Thu Jan 27 23:45:17 2022 +0100 +++ b/tests/dstest_file_readdir.cc Sun Feb 06 18:05:23 2022 +0100 @@ -1,7 +1,7 @@ /* * Test directory reading operations. * - * Copyright (C) 2020, 2021 Paul Boddie + * Copyright (C) 2020, 2021, 2022 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -31,47 +31,19 @@ -static file_t *open_directory(char *filename, bool have_uid, sys_uid_t uid) -{ - /* With a user, open a user-specific file opener. */ - - if (have_uid) - { - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022}); - - if (l4_is_invalid_cap(opener)) - { - printf("Could not obtain opener for file.\n"); - return NULL; - } - - /* Invoke the open method to receive the file reference. */ - - return client_opendir_using(filename, opener); - } - else - { - return client_opendir(filename); - } -} - - - int main(int argc, char *argv[]) { if (argc < 2) { - printf("Need a directory name and an optional user identifier (if used with a filesystem).\n"); + printf("Need a directory name.\n"); return 1; } char *filename = argv[1]; - bool have_uid = (argc > 2) && strlen(argv[2]); - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0; printf("Opening %s...\n", filename); - file_t *reader = open_directory(filename, have_uid, uid); + file_t *reader = client_opendir(filename); if (reader == NULL) { @@ -93,7 +65,7 @@ /* Open again, reading a single entry only. */ - reader = open_directory(filename, have_uid, uid); + reader = client_opendir(filename); if (reader == NULL) { diff -r b769dcb3f4b3 -r 2582a68006ff tests/dstest_file_readdir_concurrent.cc --- a/tests/dstest_file_readdir_concurrent.cc Thu Jan 27 23:45:17 2022 +0100 +++ b/tests/dstest_file_readdir_concurrent.cc Sun Feb 06 18:05:23 2022 +0100 @@ -1,7 +1,7 @@ /* * Test directory reading operations, exploring concurrency issues. * - * Copyright (C) 2020, 2021 Paul Boddie + * Copyright (C) 2020, 2021, 2022 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -31,95 +31,19 @@ -static file_t *open_directory(char *filename, bool have_uid, sys_uid_t uid) -{ - /* With a user, open a user-specific file opener. */ - - if (have_uid) - { - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022}); - - if (l4_is_invalid_cap(opener)) - { - printf("Could not obtain opener for file.\n"); - return NULL; - } - - /* Invoke the open method to receive the file reference. */ - - return client_opendir_using(filename, opener); - } - else - { - return client_opendir(filename); - } -} - -static file_t *open_file(char *filename, bool have_uid, sys_uid_t uid) -{ - /* With a user, open a user-specific file opener. */ - - if (have_uid) - { - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022}); - - if (l4_is_invalid_cap(opener)) - { - printf("Could not obtain opener for file.\n"); - return NULL; - } - - /* Invoke the open method to receive the file reference. */ - - return client_open_using(filename, O_RDWR | O_CREAT, opener); - } - else - { - return client_open(filename, O_RDWR | O_CREAT); - } -} - -static long remove_file(char *filename, bool have_uid, sys_uid_t uid) -{ - /* With a user, open a user-specific file opener. */ - - if (have_uid) - { - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022}); - - if (l4_is_invalid_cap(opener)) - { - printf("Could not obtain opener for file.\n"); - return -L4_EIO; - } - - /* Invoke the remove method to remove the file. */ - - return client_remove_using(filename, opener); - } - else - { - return client_remove(filename); - } -} - - - int main(int argc, char *argv[]) { if (argc < 2) { - printf("Need a directory name and an optional user identifier (if used with a filesystem).\n"); + printf("Need a directory name.\n"); return 1; } char *filename = argv[1]; - bool have_uid = (argc > 2) && strlen(argv[2]); - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0; printf("Opening %s...\n", filename); - file_t *reader = open_directory(filename, have_uid, uid); + file_t *reader = client_opendir(filename); if (reader == NULL) { @@ -147,7 +71,7 @@ { sprintf(buffer, "%s/file-%d.txt", filename, filenum++); - file_t *file = open_file(buffer, have_uid, uid); + file_t *file = client_open(buffer, O_RDWR | O_CREAT); if (file == NULL) { @@ -172,7 +96,7 @@ /* Re-read, counting files. */ - reader = open_directory(filename, have_uid, uid); + reader = client_opendir(filename); if (reader == NULL) { @@ -196,7 +120,7 @@ { sprintf(buffer, "%s/file-%d.txt", filename, filenum++); - long err = remove_file(buffer, have_uid, uid); + long err = client_remove(buffer); if (err) { @@ -207,7 +131,7 @@ /* Re-read, counting files. */ - reader = open_directory(filename, have_uid, uid); + reader = client_opendir(filename); if (reader == NULL) { diff -r b769dcb3f4b3 -r 2582a68006ff tests/dstest_file_rename.cc --- a/tests/dstest_file_rename.cc Thu Jan 27 23:45:17 2022 +0100 +++ b/tests/dstest_file_rename.cc Sun Feb 06 18:05:23 2022 +0100 @@ -31,71 +31,19 @@ -static file_t *open_directory(char *filename, bool have_uid, sys_uid_t uid) -{ - /* With a user, open a user-specific file opener. */ - - if (have_uid) - { - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022}); - - if (l4_is_invalid_cap(opener)) - { - printf("Could not obtain opener for file.\n"); - return NULL; - } - - /* Invoke the open method to receive the file reference. */ - - return client_opendir_using(filename, opener); - } - else - { - return client_opendir(filename); - } -} - -static long rename_file(char *source, char *target, bool have_uid, sys_uid_t uid) -{ - /* With a user, open a user-specific file opener. */ - - if (have_uid) - { - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022}); - - if (l4_is_invalid_cap(opener)) - { - printf("Could not obtain opener for file.\n"); - return -L4_EIO; - } - - /* Invoke the rename method to rename the file. */ - - return client_rename_using(source, target, opener); - } - else - { - return client_rename(source, target); - } -} - - - int main(int argc, char *argv[]) { if (argc < 2) { - printf("Need a directory name and an optional user identifier (if used with a filesystem).\n"); + printf("Need a directory name.\n"); return 1; } char *filename = argv[1]; - bool have_uid = (argc > 2) && strlen(argv[2]); - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0; printf("Opening %s...\n", filename); - file_t *reader = open_directory(filename, have_uid, uid); + file_t *reader = client_opendir(filename); if (reader == NULL) { @@ -126,7 +74,7 @@ sprintf(source, "%s/file-%d.txt", filename, filenum); sprintf(target, "%s/renamed-%d.txt", filename, filenum); - long err = rename_file(source, target, have_uid, uid); + long err = client_rename(source, target); if (err) { @@ -137,7 +85,7 @@ /* Show the new listing. */ - reader = open_directory(filename, have_uid, uid); + reader = client_opendir(filename); if (reader == NULL) {