/* * process MOVE command */ static void rfs_move(struct aipc_rfs_msg *msg) { struct aipc_rfs_move *param = (struct aipc_rfs_move*)msg->parameter; int new_name_size, old_name_size, ret; char old_name[500], new_name[500]; mm_segment_t oldfs = get_fs(); memset(old_name, 0x0, sizeof(old_name)); memset(new_name, 0x0, sizeof(new_name)); old_name_size = param->old_name_size; new_name_size = param->new_name_size; memcpy(old_name, param->name, old_name_size); memcpy(new_name, ¶m->name[old_name_size], new_name_size); /* link the original file to a new file */ set_fs(KERNEL_DS); ret = sys_link(old_name, new_name); if(ret < 0) { DMSG("rfs_move error: %d\n", ret); goto done; } /* remove the original file*/ ret = sys_unlink(old_name); done: set_fs(oldfs); msg->parameter[0] = ret; }
static int filemon_wrapper_link(struct lwp * l, struct sys_link_args * uap, register_t * retval) { int ret; int error; size_t done; struct filemon *filemon; if ((ret = sys_link(l, uap, retval)) == 0) { filemon = filemon_lookup(curproc); if (filemon) { error = copyinstr(SCARG(uap, path), filemon->fm_fname1, sizeof(filemon->fm_fname1), &done); if (error == 0) error = copyinstr(SCARG(uap, link), filemon->fm_fname2, sizeof(filemon->fm_fname2), &done); if (error == 0) { filemon_printf(filemon, "L %d '%s' '%s'\n", curproc->p_pid, filemon->fm_fname1, filemon->fm_fname2); } rw_exit(&filemon->fm_mtx); } } return (ret); }
/* Create a new link to an existing (but potentially unlinked) dentry. * If the target link already exists we return the dentry, but if the target * exists and is not a link to the desired object, we return -EEXIST. * * NOTE: We once tried to do this via vfs_link(), rather than sys_link(). * That was "better" in the sense that it was able to link to unlinked * targets (which this cannot). However, that was not working over NFS * for reasons I never did figure out. -PHH */ struct dentry * cr_link(cr_errbuf_t *eb, struct path *old_path, const char *name) { struct nameidata nd; char *buf, *old_name; struct dentry *new_dentry = NULL; int retval; mm_segment_t oldfs; /* Lookup the path to the "old" file. * This is the part that prevents us from linking to an unlinked target. */ retval = -ENOMEM; buf = __getname(); if (!buf) goto out; old_name = cr_getpath(old_path, buf, PATH_MAX); if (IS_ERR(old_name)) { retval = PTR_ERR(old_name); goto out_free; } /* Now sys_link() */ oldfs = get_fs(); set_fs(KERNEL_DS); retval = sys_link(old_name, name); set_fs(oldfs); if (retval == -EEXIST) { /* Keep going, it may be the one we want */ } else if (retval < 0) { CR_ERR_EB(eb, "cr_link: sys_link(%s,%s) returned %d", old_name, name, retval); goto out_free; } /* Now get the dentry for the newly-created object. * YES, there is a potential race, but we check below that we have the right object. */ retval = path_lookup(name, LOOKUP_FOLLOW, &nd); if (retval < 0) { CR_ERR_EB(eb, "cr_link: path_lookup(%s) returned %d", name, retval); goto out_free; } new_dentry = dget(nd.nd_dentry); cr_path_release(&nd); /* Check that we have a link to the desired object. * Needed for sys_link() == -EEXIST and for the link-to-lookup race. */ if (new_dentry->d_inode != old_path->dentry->d_inode) { dput(new_dentry); retval = -EEXIST; goto out_free; } out_free: __putname(buf); out: return (retval < 0) ? ERR_PTR(retval) : new_dentry; }
int vfswrap_link(vfs_handle_struct *handle, connection_struct *conn, const char *oldpath, const char *newpath) { int result; START_PROFILE(syscall_link); result = sys_link(oldpath, newpath); END_PROFILE(syscall_link); return result; }
void bpLink( void (*sym)( const char *t_sym,void *pc ) ){ //BASIC basic_link( sym ); sys_link( sym ); gui_link( sym ); b2d_link( sym ); }
static int syscall_dispatch(uint32_t sysnum, uint32_t args, regs_t *regs) { switch (sysnum) { case SYS_waitpid: return sys_waitpid((waitpid_args_t *)args); case SYS_exit: do_exit((int)args); panic("exit failed!\n"); return 0; case SYS_thr_exit: kthread_exit((void *)args); panic("thr_exit failed!\n"); return 0; case SYS_thr_yield: sched_make_runnable(curthr); sched_switch(); return 0; case SYS_fork: return sys_fork(regs); case SYS_getpid: return curproc->p_pid; case SYS_sync: sys_sync(); return 0; #ifdef __MOUNTING__ case SYS_mount: return sys_mount((mount_args_t *) args); case SYS_umount: return sys_umount((argstr_t *) args); #endif case SYS_mmap: return (int) sys_mmap((mmap_args_t *) args); case SYS_munmap: return sys_munmap((munmap_args_t *) args); case SYS_open: return sys_open((open_args_t *) args); case SYS_close: return sys_close((int)args); case SYS_read: return sys_read((read_args_t *)args); case SYS_write: return sys_write((write_args_t *)args); case SYS_dup: return sys_dup((int)args); case SYS_dup2: return sys_dup2((dup2_args_t *)args); case SYS_mkdir: return sys_mkdir((mkdir_args_t *)args); case SYS_rmdir: return sys_rmdir((argstr_t *)args); case SYS_unlink: return sys_unlink((argstr_t *)args); case SYS_link: return sys_link((link_args_t *)args); case SYS_rename: return sys_rename((rename_args_t *)args); case SYS_chdir: return sys_chdir((argstr_t *)args); case SYS_getdents: return sys_getdents((getdents_args_t *)args); case SYS_brk: return (int) sys_brk((void *)args); case SYS_lseek: return sys_lseek((lseek_args_t *)args); case SYS_halt: sys_halt(); return -1; case SYS_set_errno: curthr->kt_errno = (int)args; return 0; case SYS_errno: return curthr->kt_errno; case SYS_execve: return sys_execve((execve_args_t *)args, regs); case SYS_stat: return sys_stat((stat_args_t *)args); case SYS_uname: return sys_uname((struct utsname *)args); case SYS_debug: return sys_debug((argstr_t *)args); case SYS_kshell: return sys_kshell((int)args); default: dbg(DBG_ERROR, "ERROR: unknown system call: %d (args: %#08x)\n", sysnum, args); curthr->kt_errno = ENOSYS; return -1; } }
int link(const char *old_path, const char *new_path) { return sys_link(old_path, new_path); }