1.1 --- a/tests/dstest_file_rename.cc Thu Jan 27 23:45:17 2022 +0100
1.2 +++ b/tests/dstest_file_rename.cc Sun Feb 06 18:05:23 2022 +0100
1.3 @@ -31,71 +31,19 @@
1.4
1.5
1.6
1.7 -static file_t *open_directory(char *filename, bool have_uid, sys_uid_t uid)
1.8 -{
1.9 - /* With a user, open a user-specific file opener. */
1.10 -
1.11 - if (have_uid)
1.12 - {
1.13 - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022});
1.14 -
1.15 - if (l4_is_invalid_cap(opener))
1.16 - {
1.17 - printf("Could not obtain opener for file.\n");
1.18 - return NULL;
1.19 - }
1.20 -
1.21 - /* Invoke the open method to receive the file reference. */
1.22 -
1.23 - return client_opendir_using(filename, opener);
1.24 - }
1.25 - else
1.26 - {
1.27 - return client_opendir(filename);
1.28 - }
1.29 -}
1.30 -
1.31 -static long rename_file(char *source, char *target, bool have_uid, sys_uid_t uid)
1.32 -{
1.33 - /* With a user, open a user-specific file opener. */
1.34 -
1.35 - if (have_uid)
1.36 - {
1.37 - l4_cap_idx_t opener = client_open_for_user((user_t) {uid, uid, 0022});
1.38 -
1.39 - if (l4_is_invalid_cap(opener))
1.40 - {
1.41 - printf("Could not obtain opener for file.\n");
1.42 - return -L4_EIO;
1.43 - }
1.44 -
1.45 - /* Invoke the rename method to rename the file. */
1.46 -
1.47 - return client_rename_using(source, target, opener);
1.48 - }
1.49 - else
1.50 - {
1.51 - return client_rename(source, target);
1.52 - }
1.53 -}
1.54 -
1.55 -
1.56 -
1.57 int main(int argc, char *argv[])
1.58 {
1.59 if (argc < 2)
1.60 {
1.61 - printf("Need a directory name and an optional user identifier (if used with a filesystem).\n");
1.62 + printf("Need a directory name.\n");
1.63 return 1;
1.64 }
1.65
1.66 char *filename = argv[1];
1.67 - bool have_uid = (argc > 2) && strlen(argv[2]);
1.68 - sys_uid_t uid = have_uid ? atoi(argv[2]) : 0;
1.69
1.70 printf("Opening %s...\n", filename);
1.71
1.72 - file_t *reader = open_directory(filename, have_uid, uid);
1.73 + file_t *reader = client_opendir(filename);
1.74
1.75 if (reader == NULL)
1.76 {
1.77 @@ -126,7 +74,7 @@
1.78 sprintf(source, "%s/file-%d.txt", filename, filenum);
1.79 sprintf(target, "%s/renamed-%d.txt", filename, filenum);
1.80
1.81 - long err = rename_file(source, target, have_uid, uid);
1.82 + long err = client_rename(source, target);
1.83
1.84 if (err)
1.85 {
1.86 @@ -137,7 +85,7 @@
1.87
1.88 /* Show the new listing. */
1.89
1.90 - reader = open_directory(filename, have_uid, uid);
1.91 + reader = client_opendir(filename);
1.92
1.93 if (reader == NULL)
1.94 {