public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Factor out d_path printing for any dentry.
@ 2010-10-20 17:46 Erick Tryzelaar
  2010-10-20 17:46 ` [PATCH 2/2] __dentry_prepend should not always add trailing '/' Erick Tryzelaar
  2010-10-21  2:53 ` [PATCH 1/2] Factor out d_path printing for any dentry Josh Stone
  0 siblings, 2 replies; 3+ messages in thread
From: Erick Tryzelaar @ 2010-10-20 17:46 UTC (permalink / raw)
  To: systemtap; +Cc: Erick Tryzelaar

[-- Attachment #1: Type: text/plain, Size: 122 bytes --]

---
 tapset/dentry.stp |   38 ++++++++++++++++++++++++++++----------
 1 files changed, 28 insertions(+), 10 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Factor-out-d_path-printing-for-any-dentry.patch --]
[-- Type: text/x-patch; name="0001-Factor-out-d_path-printing-for-any-dentry.patch", Size: 1868 bytes --]

diff --git a/tapset/dentry.stp b/tapset/dentry.stp
index bae022d..0ed50ef 100644
--- a/tapset/dentry.stp
+++ b/tapset/dentry.stp
@@ -63,21 +63,18 @@ function reverse_path_walk:string(dentry:long)
 
 
 /**
- *   sfunction d_path - get the full nameidata path
+ *   sfunction task_dentry_path - get the full dentry path
  *
  *   Returns the full dirent name (full path to the root), like
  *   the kernel d_path function.
- *   @nd: Pointer to nameidata.
+ *   @task: task_struct pointer.
+ *   @dentry: direntry pointer.
+ *   @vfsmnt: vfsmnt pointer.
  */
-function d_path:string(nd:long)
+function task_dentry_path:string(task:long,dentry:long,vfsmnt:long)
 {
-        root = & @cast(task_current(), "task_struct")->fs->root
-	dentry = (@defined(@cast(nd,"nameidata")->path->dentry)
-	    ? @cast(nd,"nameidata")->path->dentry
-	    : @cast(nd,"nameidata")->dentry)
-	vfsmnt = (@defined(@cast(nd,"nameidata")->path->mnt)
-	    ? @cast(nd,"nameidata")->path->mnt
-	    : @cast(nd,"nameidata")->mnt)
+        root = & @cast(task, "task_struct")->fs->root
+
         while (1) {
                 if (dentry == @cast(root, "path")->dentry &&
                     vfsmnt == @cast(root, "path")->mnt)
@@ -99,3 +96,24 @@ function d_path:string(nd:long)
 
         return sprintf("/%s", name);
 }
+
+
+
+/**
+ *   sfunction d_path - get the full nameidata path
+ *
+ *   Returns the full dirent name (full path to the root), like
+ *   the kernel d_path function.
+ *   @nd: Pointer to nameidata.
+ */
+function d_path:string(nd:long)
+{
+	dentry = (@defined(@cast(nd,"nameidata")->path->dentry)
+	    ? @cast(nd,"nameidata")->path->dentry
+	    : @cast(nd,"nameidata")->dentry)
+	vfsmnt = (@defined(@cast(nd,"nameidata")->path->mnt)
+	    ? @cast(nd,"nameidata")->path->mnt
+	    : @cast(nd,"nameidata")->mnt)
+
+	return task_dentry_path(task_current(), dentry, vfsmnt)
+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] __dentry_prepend should not always add trailing '/'
  2010-10-20 17:46 [PATCH 1/2] Factor out d_path printing for any dentry Erick Tryzelaar
@ 2010-10-20 17:46 ` Erick Tryzelaar
  2010-10-21  2:53 ` [PATCH 1/2] Factor out d_path printing for any dentry Josh Stone
  1 sibling, 0 replies; 3+ messages in thread
From: Erick Tryzelaar @ 2010-10-20 17:46 UTC (permalink / raw)
  To: systemtap; +Cc: Erick Tryzelaar

[-- Attachment #1: Type: text/plain, Size: 90 bytes --]

---
 tapset/dentry.stp |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-__dentry_prepend-should-not-always-add-trailing.patch --]
[-- Type: text/x-patch; name="0002-__dentry_prepend-should-not-always-add-trailing.patch", Size: 739 bytes --]

diff --git a/tapset/dentry.stp b/tapset/dentry.stp
index 0ed50ef..9c89d38 100644
--- a/tapset/dentry.stp
+++ b/tapset/dentry.stp
@@ -25,7 +25,11 @@ function __dentry_prepend:string(dentry:long,name:string)
         if (dname == "/" && c == "/")
                 return name;
 
-        return sprintf("%s/%s", dname, name);
+        if (name == "") {
+                return dname;
+        } else {
+                return sprintf("%s/%s", dname, name);
+        }
 }
 
 
@@ -115,5 +119,5 @@ function d_path:string(nd:long)
 	    ? @cast(nd,"nameidata")->path->mnt
 	    : @cast(nd,"nameidata")->mnt)
 
-	return task_dentry_path(task_current(), dentry, vfsmnt)
+	return sprintf("%s/", task_dentry_path(task_current(), dentry, vfsmnt))
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] Factor out d_path printing for any dentry.
  2010-10-20 17:46 [PATCH 1/2] Factor out d_path printing for any dentry Erick Tryzelaar
  2010-10-20 17:46 ` [PATCH 2/2] __dentry_prepend should not always add trailing '/' Erick Tryzelaar
@ 2010-10-21  2:53 ` Josh Stone
  1 sibling, 0 replies; 3+ messages in thread
From: Josh Stone @ 2010-10-21  2:53 UTC (permalink / raw)
  To: Erick Tryzelaar; +Cc: systemtap

On 10/20/2010 10:46 AM, Erick Tryzelaar wrote:
> ---
>  tapset/dentry.stp |   38 ++++++++++++++++++++++++++++----------
>  1 files changed, 28 insertions(+), 10 deletions(-)
> 

Thanks, I've pushed both of these.

When adding a new function, please consider what testing can be done for
it.  We don't have much testing in place for the dentry functions, but I
did add your new function to testsuite/buildok/dentry-embedded.stp
(Even though it was indirectly there via d_path(), it's good to
explicitly test everything we can.)

Josh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-10-21  2:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-20 17:46 [PATCH 1/2] Factor out d_path printing for any dentry Erick Tryzelaar
2010-10-20 17:46 ` [PATCH 2/2] __dentry_prepend should not always add trailing '/' Erick Tryzelaar
2010-10-21  2:53 ` [PATCH 1/2] Factor out d_path printing for any dentry Josh Stone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).