svn commit: r297172 - head/sys/dev/filemon
Bryan Drewery
bdrewery at FreeBSD.org
Mon Mar 21 23:22:20 UTC 2016
Author: bdrewery
Date: Mon Mar 21 23:22:19 2016
New Revision: 297172
URL: https://svnweb.freebsd.org/changeset/base/297172
Log:
Consolidate common link(2) logic.
MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
Modified:
head/sys/dev/filemon/filemon_wrapper.c
Modified: head/sys/dev/filemon/filemon_wrapper.c
==============================================================================
--- head/sys/dev/filemon/filemon_wrapper.c Mon Mar 21 22:29:24 2016 (r297171)
+++ head/sys/dev/filemon/filemon_wrapper.c Mon Mar 21 23:22:19 2016 (r297172)
@@ -237,58 +237,46 @@ filemon_wrapper_rename(struct thread *td
return (ret);
}
-static int
-filemon_wrapper_link(struct thread *td, struct link_args *uap)
+static void
+_filemon_wrapper_link(struct thread *td, char *upath1, char *upath2)
{
- int ret;
- size_t done;
- size_t len;
struct filemon *filemon;
+ size_t len;
- if ((ret = sys_link(td, uap)) == 0) {
- if ((filemon = filemon_proc_get(curproc)) != NULL) {
- copyinstr(uap->path, filemon->fname1,
- sizeof(filemon->fname1), &done);
- copyinstr(uap->link, filemon->fname2,
- sizeof(filemon->fname2), &done);
+ if ((filemon = filemon_proc_get(curproc)) != NULL) {
+ copyinstr(upath1, filemon->fname1,
+ sizeof(filemon->fname1), NULL);
+ copyinstr(upath2, filemon->fname2,
+ sizeof(filemon->fname2), NULL);
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "L %d '%s' '%s'\n",
- curproc->p_pid, filemon->fname1, filemon->fname2);
+ len = snprintf(filemon->msgbufr,
+ sizeof(filemon->msgbufr), "L %d '%s' '%s'\n",
+ curproc->p_pid, filemon->fname1, filemon->fname2);
- filemon_output(filemon, filemon->msgbufr, len);
+ filemon_output(filemon, filemon->msgbufr, len);
- filemon_drop(filemon);
- }
+ filemon_drop(filemon);
}
-
- return (ret);
}
static int
-filemon_wrapper_symlink(struct thread *td, struct symlink_args *uap)
+filemon_wrapper_link(struct thread *td, struct link_args *uap)
{
int ret;
- size_t done;
- size_t len;
- struct filemon *filemon;
- if ((ret = sys_symlink(td, uap)) == 0) {
- if ((filemon = filemon_proc_get(curproc)) != NULL) {
- copyinstr(uap->path, filemon->fname1,
- sizeof(filemon->fname1), &done);
- copyinstr(uap->link, filemon->fname2,
- sizeof(filemon->fname2), &done);
+ if ((ret = sys_link(td, uap)) == 0)
+ _filemon_wrapper_link(td, uap->path, uap->link);
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "L %d '%s' '%s'\n",
- curproc->p_pid, filemon->fname1, filemon->fname2);
+ return (ret);
+}
- filemon_output(filemon, filemon->msgbufr, len);
+static int
+filemon_wrapper_symlink(struct thread *td, struct symlink_args *uap)
+{
+ int ret;
- filemon_drop(filemon);
- }
- }
+ if ((ret = sys_symlink(td, uap)) == 0)
+ _filemon_wrapper_link(td, uap->path, uap->link);
return (ret);
}
@@ -297,26 +285,9 @@ static int
filemon_wrapper_linkat(struct thread *td, struct linkat_args *uap)
{
int ret;
- size_t done;
- size_t len;
- struct filemon *filemon;
-
- if ((ret = sys_linkat(td, uap)) == 0) {
- if ((filemon = filemon_proc_get(curproc)) != NULL) {
- copyinstr(uap->path1, filemon->fname1,
- sizeof(filemon->fname1), &done);
- copyinstr(uap->path2, filemon->fname2,
- sizeof(filemon->fname2), &done);
-
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "L %d '%s' '%s'\n",
- curproc->p_pid, filemon->fname1, filemon->fname2);
-
- filemon_output(filemon, filemon->msgbufr, len);
- filemon_drop(filemon);
- }
- }
+ if ((ret = sys_linkat(td, uap)) == 0)
+ _filemon_wrapper_link(td, uap->path1, uap->path2);
return (ret);
}
More information about the svn-src-all
mailing list