#include #include #include #define CHECK(cond) if( !(cond) ) { printf("%s failed at %s:%d\n", #cond, __FILE__, __LINE__); exit(1); } const char *fname = "//s-cw-head/pgas/test.bin"; // Works with simple "c:/test.bin" int main() { // Without this snippet everything works int perm = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; int mode = O_WRONLY | O_CREAT | O_TRUNC; int fd = open(fname, mode, perm); CHECK( -1 != fd ); close(fd); // Main part FILE *p = fopen(fname, "rb+"); CHECK(p); long long data = -1; CHECK( sizeof(data) == fwrite(&data, 1, sizeof(data), p) ); CHECK( 0 == fseek(p, 0, SEEK_END) ); CHECK( ftell(p) == sizeof(data) ); printf("success\n"); return 0; }