src/open_by_handle: verify dir content only with -r flag
authorAmir Goldstein <amir73il@gmail.com>
Tue, 23 Jan 2018 20:59:06 +0000 (22:59 +0200)
committerEryu Guan <eguan@redhat.com>
Wed, 24 Jan 2018 07:40:39 +0000 (15:40 +0800)
Without -r flag file handles are opened, but file content is not
read.  Treat dir file hanldes, similarly. without -r flag, open dir
file handle, but don't verify its content.

This is going to be used by tests for which dir content is changed
between encode and decode of dir file handle.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
src/open_by_handle.c

index dbc5b0f4d0affad8e632ccd92aedeb3f803431aa..9c13b2ab072b8173d6592bb5ddfbf775119013b2 100644 (file)
@@ -412,7 +412,7 @@ int main(int argc, char **argv)
                        if (!nlink) {
                                printf("open_by_handle(%s) opened an unlinked dir!\n", dname);
                                return EXIT_FAILURE;
                        if (!nlink) {
                                printf("open_by_handle(%s) opened an unlinked dir!\n", dname);
                                return EXIT_FAILURE;
-                       } else {
+                       } else if (rd) {
                                /*
                                 * Sanity check dir fd - expect to access orig file IFF
                                 * it was not unlinked nor renamed.
                                /*
                                 * Sanity check dir fd - expect to access orig file IFF
                                 * it was not unlinked nor renamed.