TEST(sys_statvfs, fstatvfs64) {
  struct statvfs64 sb;
  int fd = open("/proc", O_RDONLY);
  ASSERT_EQ(0, fstatvfs64(fd, &sb));
  close(fd);
  Check(sb);
}
Пример #2
0
int
fstatfs64(int fd, struct statfs64 *buf)
{
	int ret;
	struct statvfs64 vbuf;

	if ((ret = fstatvfs64(fd, &vbuf)) != -1)
		cnvtvfs64(buf, &vbuf);
	return (ret);
}
Пример #3
0
int archwriter_write_buffer(carchwriter *ai, struct s_writebuf *wb)
{
    struct statvfs64 statvfsbuf;
    char textbuf[128];
    long lres;
    
    assert(ai);
    assert(wb);

    if (wb->size == 0)
    {   errprintf("wb->size=%ld\n", (long)wb->size);
        return -1;
    }

    if ((lres=write(ai->archfd, (char*)wb->data, (long)wb->size))!=(long)wb->size)
    {
        errprintf("write(size=%ld) returned %ld\n", (long)wb->size, (long)lres);
        if ((lres>0) && (lres < (long)wb->size)) // probably "no space left"
        {
            if (fstatvfs64(ai->archfd, &statvfsbuf)!=0)
            {   sysprintf("fstatvfs(fd=%d) failed\n", ai->archfd);
                return -1;
            }
            
            u64 freebytes = statvfsbuf.f_bfree * statvfsbuf.f_bsize;
            errprintf("Can't write to the archive file. Space on device is %s. \n"
                "If the archive is being written to a FAT filesystem, you may have reached \n"
                "the maximum filesize that it can handle (in general 2 GB)\n", 
                format_size(freebytes, textbuf, sizeof(textbuf), 'h'));
             werte_uebergeben (109,4);     
            return -1;
        }
        else // another error
        {
            sysprintf("write(size=%ld) failed\n", (long)wb->size);
            return -1;
        }
    }
    
    return 0;
}