SYSCALL_DEFINE3(write, unsigned int, fd, const char __user *, buf, size_t, count) { struct file *file; ssize_t ret = -EBADF; int fput_needed; #ifdef CONFIG_DIRTY_SYSTEM_DETECTOR #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) struct mount *mnt; #else struct vfsmount *mnt; #endif #endif file = fget_light(fd, &fput_needed); #ifdef CONFIG_DIRTY_SYSTEM_DETECTOR if (!get_tamper_sf() && file != NULL) { if (board_mfg_mode() != 2 && strcmp("htcunzip", current->comm)) { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) mnt = real_mount(file->f_path.mnt); #else mnt = file->f_path.mnt; #endif if (!strcmp("system", mnt->mnt_mountpoint->d_name.name)) { printk("%s to /system partition: file(%s)\n", __func__, file->f_path.dentry->d_name.name); mark_system_dirty(file->f_path.dentry->d_name.name); } } } #endif if (file) { loff_t pos = file_pos_read(file); ret = vfs_write(file, buf, count, &pos); file_pos_write(file, pos); fput_light(file, fput_needed); } return ret; }
SYSCALL_DEFINE3(write, unsigned int, fd, const char __user *, buf, size_t, count) { struct file *file; ssize_t ret = -EBADF; int fput_needed; #ifdef CONFIG_DIRTY_SYSTEM_DETECTOR #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) struct mount *mnt; #else struct vfsmount *mnt; #endif #endif file = fget_light(fd, &fput_needed); #ifdef CONFIG_DIRTY_SYSTEM_DETECTOR if (!get_tamper_sf() && file != NULL) { if (board_mfg_mode() != 2 && strcmp("htcunzip", current->comm)) { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) mnt = real_mount(file->f_path.mnt); #else mnt = file->f_path.mnt; #endif if (!strcmp("system", mnt->mnt_mountpoint->d_name.name)) { printk("%s to /system partition: file(%s)\n", __func__, file->f_path.dentry->d_name.name); mark_system_dirty(file->f_path.dentry->d_name.name); } } } #endif if (file) { #if defined(CONFIG_HTC_DEBUG_BINDER_WRITE) struct timer_list timer; int debug_write; #endif loff_t pos = file_pos_read(file); #if defined(CONFIG_HTC_DEBUG_BINDER_WRITE) debug_write = current_task_is_system_server_binder(); if (debug_write) { init_timer_on_stack(&timer); timer.function = vfs_write_timeout; timer.expires = jiffies + HZ * WRITE_TIMEOUT_VALUE; timer.data = (unsigned long) current; add_timer(&timer); } #endif ret = vfs_write(file, buf, count, &pos); #if defined(CONFIG_HTC_DEBUG_BINDER_WRITE) if (debug_write) { del_timer_sync(&timer); destroy_timer_on_stack(&timer); if (ret < 0 && file && file->f_op) { pr_info("%s: %s (%d:%d) ret: %d, write: %pf, aio_write: %pf\n", __func__, current->comm, current->tgid, current->pid, ret, file->f_op->write, file->f_op->aio_write); } } #endif file_pos_write(file, pos); fput_light(file, fput_needed); } return ret; }