Re: cifs conversion to netfslib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Howells <dhowells@xxxxxxxxxx> wrote:

> The other issue is that if I run splice to an empty file, it works; running
> another splice to the same file will result in the server giving
> STATUS_ACCESS_DENIED when cifs_write_begin() tries to read from the file:
> 
>     7 0.009485249  192.168.6.2 → 192.168.6.1  SMB2 183 Read Request Len:65536 Off:0 File: x
>     8 0.009674245  192.168.6.1 → 192.168.6.2  SMB2 143 Read Response, Error: STATUS_ACCESS_DENIED
> 
> Actually - that might be because the file is only 65536 bytes long because the
> first splice finished short.

Actually, it's because I opened the output file O_WRONLY.  If I open it
O_RDWR, it works.  The test program is attached below.

David
---
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>

int main(int argc, char *argv[])
{
	off64_t opos;
	size_t len;
	int in, out;

	if (argc != 4) {
		printf("Format: %s size in out\n", argv[0]);
		exit(2);
	}

	len = atol(argv[1]);

	if (strcmp(argv[2], "-") != 0) {
		in = open(argv[2], O_RDONLY);
		if (in < 0) {
			perror(argv[2]);
			return 1;
		}
	} else {
		in = 0;
	}

	if (strcmp(argv[3], "-") != 0) {
		out = open(argv[3], O_WRONLY);  // Change to O_RDWR
		if (out < 0) {
			perror(argv[3]);
			return 1;
		}
	} else {
		out = 1;
	}

	opos = 3;
	if (splice(in, NULL, out, &opos, len, 0) < 0) {
		perror("splice");
		return 1;
	}

	if (close(in) < 0) {
		perror("close/in");
		return 1;
	}

	if (close(out) < 0) {
		perror("close/out");
		return 1;
	}

	return 0;
}





[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux