]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
proc: smoke test lseek()
authorAlexey Dobriyan <adobriyan@gmail.com>
Tue, 13 Apr 2021 22:21:12 +0000 (08:21 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 13 Apr 2021 22:21:12 +0000 (08:21 +1000)
Now that ->proc_lseek has been made mandatory it would be nice to test
that nothing has been forgotten.

Link: https://lkml.kernel.org/r/YG4OIhChOrVTPgdN@localhost.localdomain
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
tools/testing/selftests/proc/read.c

index b3ef9e14d6ccfeb8d0b2470ebec15fbb073db504..35ee78dff14448cdd7762bf9851bbe6564deedec 100644 (file)
@@ -14,7 +14,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 // Test
-// 1) read of every file in /proc
+// 1) read and lseek on every file in /proc
 // 2) readlink of every symlink in /proc
 // 3) recursively (1) + (2) for every directory in /proc
 // 4) write to /proc/*/clear_refs and /proc/*/task/*/clear_refs
@@ -45,6 +45,8 @@ static void f_reg(DIR *d, const char *filename)
        fd = openat(dirfd(d), filename, O_RDONLY|O_NONBLOCK);
        if (fd == -1)
                return;
+       /* struct proc_ops::proc_lseek is mandatory if file is seekable. */
+       (void)lseek(fd, 0, SEEK_SET);
        rv = read(fd, buf, sizeof(buf));
        assert((0 <= rv && rv <= sizeof(buf)) || rv == -1);
        close(fd);