Exemplo n.º 1
0
SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
{
	if (!fsync_enabled)
			return 0;

	return do_fsync(fd, 1);
}
Exemplo n.º 2
0
SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
{
	#ifdef CONFIG_FSYNC_OFF
		return 0;
	#endif
	return do_fsync(fd, 1);
}
Exemplo n.º 3
0
SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
{
	//conditional fsync disable
	#ifdef CONFIG_FSYNC_OFF
	  return 0;
	#endif
	return do_fsync(fd, 1);
}
Exemplo n.º 4
0
SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
{
#ifdef CONFIG_FSYNC_CONTROL
	if (!fsynccontrol_fsync_enabled())
		return 0;
#endif
	return do_fsync(fd, 1);
}
Exemplo n.º 5
0
SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
{
#ifdef CONFIG_DYNAMIC_FSYNC
	if (likely(dyn_fsync_active && suspend_active))
		return 0;
#endif
	return do_fsync(fd, 1);
}
Exemplo n.º 6
0
SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
{
#if 0
	if (likely(dyn_fsync_active && !power_suspend_active))
		return 0;
	else
#endif
	return do_fsync(fd, 1);
}
Exemplo n.º 7
0
SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
{
#ifdef CONFIG_DYNAMIC_FSYNC
	if (dyn_fsync_active && !dyn_fsync_can_sync)
		return 0;
#endif

	return do_fsync(fd, 1);
}
Exemplo n.º 8
0
SYSCALL_DEFINE1(fsync, unsigned int, fd)
{
#ifdef CONFIG_DYNAMIC_FSYNC
	if (likely(dyn_fsync_active && !early_suspend_active))
		return 0;
	else
#endif
	return do_fsync(fd, 0);
}
Exemplo n.º 9
0
SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
{
	#ifdef CONFIG_DYNAMIC_FSYNC
	  if (!early_suspend_active)
	    return 0;
	  else
	#endif
	return do_fsync(fd, 1);
}
Exemplo n.º 10
0
 void close() final {
     if (m_fd >= 0) {
         int fd = m_fd;
         m_fd = -1;
         if (do_fsync()) {
             osmium::io::detail::reliable_fsync(fd);
         }
         osmium::io::detail::reliable_close(fd);
     }
 }
Exemplo n.º 11
0
SYSCALL_DEFINE1(fsync, unsigned int, fd)
{
#ifdef CONFIG_DYNAMIC_FSYNC
	if (likely(dyn_fsync_active && !power_suspend_active))
		return 0;
	else
#endif
	if (!fsync_enabled)
		return 0;
	return do_fsync(fd, 0);
}
Exemplo n.º 12
0
static long __do_fsync(unsigned int fd, int datasync)
{
	struct file *file;
	int ret = -EBADF;

	file = fget(fd);
	if (file) {
		ret = do_fsync(file, datasync);
		fput(file);
	}
	return ret;
}
Exemplo n.º 13
0
 void close() final {
     if (m_gzfile) {
         const int result = ::gzclose(m_gzfile);
         m_gzfile = nullptr;
         if (result != Z_OK) {
             detail::throw_gzip_error(m_gzfile, "write close failed", result);
         }
         if (do_fsync()) {
             osmium::io::detail::reliable_fsync(m_fd);
         }
         osmium::io::detail::reliable_close(m_fd);
     }
 }
Exemplo n.º 14
0
SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
{
#ifdef CONFIG_FSYNC_CONTROL
	if (!fsynccontrol_fsync_enabled)
	    return 0;
#endif

#ifdef CONFIG_DYNAMIC_FSYNC
	if (likely(dyn_fsync_active && !early_suspend_active))
		return 0;
#endif
	return do_fsync(fd, 1);
}
Exemplo n.º 15
0
SYSCALL_DEFINE1(fsync, unsigned int, fd)
{
#ifdef CONFIG_DYNAMIC_FSYNC
	if (!early_suspend_active)
		return 0;
	else
#endif
#ifdef CONFIG_FSYNC_CONTROL
	if (!fsynccontrol_fsync_enabled())
		return 0;
#endif
	return do_fsync(fd, 0);
}
Exemplo n.º 16
0
 void close() final {
     if (m_bzfile) {
         int error;
         ::BZ2_bzWriteClose(&error, m_bzfile, 0, nullptr, nullptr);
         m_bzfile = nullptr;
         if (m_file) {
             if (do_fsync()) {
                 osmium::io::detail::reliable_fsync(::fileno(m_file));
             }
             if (fclose(m_file) != 0) {
                 throw std::system_error(errno, std::system_category(), "Close failed");
             }
         }
         if (error != BZ_OK) {
             detail::throw_bzip2_error(m_bzfile, "write close failed", error);
         }
     }
 }
Exemplo n.º 17
0
static void rkusb_xfer_free_fi( struct rkusb_dev *dev )
{
        FILE_INFO               *fi = (FILE_INFO*)dev->private_tmp;
        if( !fi )
                return ;
        if( fi->file ) {
                if( FI_WRITE(fi) ) {
                        do_fsync( fi->file , 1 );
                }
                fput( fi->file );
                if( fi->error && fi->error != -FI_ERR_CLEAR  && FI_WRITE(fi) ) {
                        rk28printk("%s::write file %s error=%d , unlink it\n" , __func__ , fi->file_path , fi->error );
                        sys_unlink( fi->file_path );
                }
        }
        kfree( fi );
        dev->private_tmp = NULL;
}
Exemplo n.º 18
0
static void reset_block_stats( const char *dev_name, const char *mount_dir )
{
  int fd;
  int rv;


  do_fsync( mount_dir );

  fd = open( dev_name, O_RDONLY );
  rtems_test_assert( fd >= 0 );

  rv = ioctl( fd, RTEMS_BLKIO_PURGEDEV );
  rtems_test_assert( rv == 0 );

  rv = ioctl( fd, RTEMS_BLKIO_RESETDEVSTATS );
  rtems_test_assert( rv == 0 );

  rv = close( fd );
  rtems_test_assert( rv == 0 );
}
Exemplo n.º 19
0
static void check_block_stats( const char *dev_name,
  const char                              *mount_dir,
  const rtems_blkdev_stats                *expected_stats )
{
  int                fd;
  int                rv;
  rtems_blkdev_stats actual_stats;


  do_fsync( mount_dir );

  fd = open( dev_name, O_RDONLY );
  rtems_test_assert( fd >= 0 );

  rv = ioctl( fd, RTEMS_BLKIO_GETDEVSTATS, &actual_stats );
  rtems_test_assert( rv == 0 );
  rtems_test_assert( memcmp( &actual_stats, expected_stats,
                             sizeof( actual_stats ) ) == 0 );

  rv = close( fd );
  rtems_test_assert( rv == 0 );
}
Exemplo n.º 20
0
int rk28_write_file( char *filename )
{
        char *procmtd = "/proc/mtd";
        struct file			*filp = NULL;
        loff_t		                pos;
        long    fd;
        
        ssize_t l=0;
        char    pathname[64];
        char    buf[1024] ;
        mm_segment_t old_fs;
        struct rtc_time tm;
        ktime_t now;        
        char *tmpbuf; 
        int     mtdidx=0;
        int mtdsize = 0x200000; // 2M 
        char *log_buf;
        int     log_len;

        debug_print("%s: filename=%s\n" , __func__ , filename );

        old_fs = get_fs();
        set_fs(KERNEL_DS);        
        fd = sys_open( procmtd , O_RDONLY , 0 );
        if( fd >= 0 ) {
                memset( buf , 0 , 1024 );
                l = sys_read( fd , buf , 1024 );
               // debug_print("/proc/mtd,total byte=%d\n" , l );
                tmpbuf = strstr( buf , filename );
                if( tmpbuf ) {
                        tmpbuf[10] = 0;
                        mtdsize = simple_strtoul(tmpbuf-19, NULL , 16);
                        mtdidx = tmpbuf[-22];
                        //debug_print("size=%s\n,idx=%s\nmtdsize=%x , mtdidx=%d" , tmpbuf-19 , tmpbuf - 22 ,
                        //        mtdsize , mtdidx );
                        mtdsize *= 512;
                        mtdidx -= '0';
                }
                sys_close( fd );
        } else {
                debug_print("open %s failed\n" , procmtd );
        }
        sprintf(pathname , "/dev/block/mtdblock%d" , mtdidx );
        filp = filp_open(pathname, O_WRONLY , 0);
        if( IS_ERR(filp) ) {
                debug_print("open %s failed n" , pathname  );
                goto out_print;
        }
        if (!(filp->f_op->write || filp->f_op->aio_write)) {
                debug_print("can not write file %s \n" , pathname  );
                goto close_file;
        }
        now = ktime_get();
        rtc_time_to_tm( now.tv.sec , &tm );
        printk( "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
                          "++++++++++RECORD LOG AT %04d-%02d-%02d %02d:%02d:%02d++++++++++\n"
                          "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n\n\n"
                          ,
                tm.tm_year+1900 , tm.tm_mon , tm.tm_mday , tm.tm_hour , tm.tm_min , tm.tm_sec );
        /* 20090924,HSL,FTL only intial first 256M at loader , MUST write 32 sector one time */
        //debug_print("write first pack , pos=%d\n" , pos ); /* pos = 2 ?? */
        kernel_getlog(&log_buf , NULL ,  &log_len );
        log_len = (log_len+(32*512-1)) / (32*512) * (32*512);
        pos = 0;
        l = vfs_write( filp , log_buf  , log_len , &pos );
        do_fsync(filp, 1);
close_file:
        filp_close(filp , NULL);
out_print:  
        set_fs(old_fs);
        debug_print("\nlog len=%d,write=%d\n" ,log_len , l);
        return 0x2b;
}
Exemplo n.º 21
0
/*
 * MS_SYNC syncs the entire file - including mappings.
 *
 * MS_ASYNC does not start I/O (it used to, up to 2.5.67).
 * Nor does it marks the relevant pages dirty (it used to up to 2.6.17).
 * Now it doesn't do anything, since dirty pages are properly tracked.
 *
 * The application may now run fsync() to
 * write out the dirty pages and wait on the writeout and check the result.
 * Or the application may run fadvise(FADV_DONTNEED) against the fd to start
 * async writeout immediately.
 * So by _not_ starting I/O in MS_ASYNC we provide complete flexibility to
 * applications.
 */
SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
{
	unsigned long end;
	struct mm_struct *mm = current->mm;
	struct vm_area_struct *vma;
	int unmapped_error = 0;
	int error = -EINVAL;

	if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC))
		goto out;
	if (start & ~PAGE_MASK)
		goto out;
	if ((flags & MS_ASYNC) && (flags & MS_SYNC))
		goto out;
	error = -ENOMEM;
	len = (len + ~PAGE_MASK) & PAGE_MASK;
	end = start + len;
	if (end < start)
		goto out;
	error = 0;
	if (end == start)
		goto out;
	/*
	 * If the interval [start,end) covers some unmapped address ranges,
	 * just ignore them, but return -ENOMEM at the end.
	 */
	down_read(&mm->mmap_sem);
	vma = find_vma(mm, start);
	for (;;) {
		struct file *file;

		/* Still start < end. */
		error = -ENOMEM;
		if (!vma)
			goto out_unlock;
		/* Here start < vma->vm_end. */
		if (start < vma->vm_start) {
			start = vma->vm_start;
			if (start >= end)
				goto out_unlock;
			unmapped_error = -ENOMEM;
		}
		/* Here vma->vm_start <= start < vma->vm_end. */
		if ((flags & MS_INVALIDATE) &&
				(vma->vm_flags & VM_LOCKED)) {
			error = -EBUSY;
			goto out_unlock;
		}
		file = vma->vm_file;
		start = vma->vm_end;
		if ((flags & MS_SYNC) && file &&
				(vma->vm_flags & VM_SHARED)) {
			get_file(file);
			up_read(&mm->mmap_sem);
			error = do_fsync(file, 0);
			fput(file);
			if (error || start >= end)
				goto out;
			down_read(&mm->mmap_sem);
			vma = find_vma(mm, start);
		} else {
			if (start >= end) {
				error = 0;
				goto out_unlock;
			}
			vma = vma->vm_next;
		}
	}
out_unlock:
	up_read(&mm->mmap_sem);
out:
	return error ? : unmapped_error;
}
Exemplo n.º 22
0
SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
{
	return 0;
	return do_fsync(fd, 1);
}
Exemplo n.º 23
0
SYSCALL_DEFINE1(fsync, unsigned int, fd)
{
	return do_fsync(fd, 0);
}
Exemplo n.º 24
0
asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
{
	unsigned long end;
	struct vm_area_struct *vma;
	int unmapped_error = 0;
	int error = -EINVAL;
	int done = 0;

	if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC))
		goto out;
	if (start & ~PAGE_MASK)
		goto out;
	if ((flags & MS_ASYNC) && (flags & MS_SYNC))
		goto out;
	error = -ENOMEM;
	len = (len + ~PAGE_MASK) & PAGE_MASK;
	end = start + len;
	if (end < start)
		goto out;
	error = 0;
	if (end == start)
		goto out;
	/*
	 * If the interval [start,end) covers some unmapped address ranges,
	 * just ignore them, but return -ENOMEM at the end.
	 */
	down_read(&current->mm->mmap_sem);
	vma = find_vma(current->mm, start);
	if (!vma) {
		error = -ENOMEM;
		goto out_unlock;
	}
	do {
		unsigned long nr_pages_dirtied = 0;
		struct file *file;

		/* Here start < vma->vm_end. */
		if (start < vma->vm_start) {
			unmapped_error = -ENOMEM;
			start = vma->vm_start;
		}
		/* Here vma->vm_start <= start < vma->vm_end. */
		if (end <= vma->vm_end) {
			if (start < end) {
				error = msync_interval(vma, start, end, flags,
							&nr_pages_dirtied);
				if (error)
					goto out_unlock;
			}
			error = unmapped_error;
			done = 1;
		} else {
			/* Here vma->vm_start <= start < vma->vm_end < end. */
			error = msync_interval(vma, start, vma->vm_end, flags,
						&nr_pages_dirtied);
			if (error)
				goto out_unlock;
		}
		file = vma->vm_file;
		start = vma->vm_end;
		if ((flags & MS_ASYNC) && file && nr_pages_dirtied) {
			get_file(file);
			up_read(&current->mm->mmap_sem);
			balance_dirty_pages_ratelimited_nr(file->f_mapping,
							nr_pages_dirtied);
			fput(file);
			down_read(&current->mm->mmap_sem);
			vma = find_vma(current->mm, start);
		} else if ((flags & MS_SYNC) && file &&
				(vma->vm_flags & VM_SHARED)) {
			get_file(file);
			up_read(&current->mm->mmap_sem);
			error = do_fsync(file, 0);
			fput(file);
			down_read(&current->mm->mmap_sem);
			if (error)
				goto out_unlock;
			vma = find_vma(current->mm, start);
		} else {
			vma = vma->vm_next;
		}
	} while (vma && !done);
out_unlock:
	up_read(&current->mm->mmap_sem);
out:
	return error;
}