Skip to contentSkip to conversation

Is grant_read() runnable?

RFC In review Akio Takebe 1 participant 2 messages Jan 25, 2006 – Jan 26, 2006

lore
Share & tools
lore
#0 lore raw

RFC 1/1 Is grant_read() runnable?

Hi, all

I think grant_read() is not runnable.
" (len > (PAGE_SIZE - 200)) " is not entered into if sentence becase of len=0.
So i always equal NR_GRANT_ENTRIES.

Is the below patch correct?
Please comment.

Best Regards,

Akio Takebe

linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c Wed Jan 25 17:01:03 2006 renamed from linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c Tue Jan 24 16:54:34 2006 +13 -13
diff -r a38c292e8390 linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c
@@ -361,22 +361,22 @@
        len = 0;
 
        for (i = 0; i < NR_GRANT_ENTRIES; i++) {
-               if (len > (PAGE_SIZE - 200)) {
+               if (len < (PAGE_SIZE - 200)) {
                        len += sprintf( page + len, "Truncated.\n");
                        break;
                }
-       }
-
-       if (gt[i].flags) {
-               len += sprintf(page + len,
-                              "Grant: ref (0x%x) flags (0x%hx) "
-                              "dom (0x%hx) frame (0x%x)\n", 
-                              i,
-                              gt[i].flags,
-                              gt[i].domid,
-                              gt[i].frame );
-       }
-
+
+               if (gt[i].flags) {
+                       len += sprintf(page + len,
+                                      "Grant: ref (0x%x) flags (0x%hx) "
+                                      "dom (0x%hx) frame (0x%x)\n", 
+                                      i,
+                                      gt[i].flags,
+                                      gt[i].domid,
+                                      gt[i].frame );
+               }
+
+       }
        *eof = 1;
        return len;
 }
#1 lore raw

Hi, all

I'm sorry for poor English.
I rewrite my mail.

Even if/proc/xen/grant is read, nothing is displayed probably. I comment to the following sources.

So I make patch. Is my patch correct?

----------------------
static int
grant_read(char *page, char **start, off_t off, int count, int *eof,
void *data)

{
        int             len;
        unsigned int    i;
        grant_entry_t  *gt;

        gt = (grant_entry_t *)shared;
        len = 0; 

        for (i = 0; i < NR_GRANT_ENTRIES; i++) {
                if (len > (PAGE_SIZE - 200)) {    <---- always FAIL
                        len += sprintf( page + len, "Truncated.\n");
                        break;
                }
        }

        if (gt[i].flags) {   <--- always gt[NR_GRANT_ENTRIES].flags
                len += sprintf(page + len,
                               "Grant: ref (0x%x) flags (0x%hx) "
                               "dom (0x%hx) frame (0x%x)\n", 
                               i,
                               gt[i].flags,
                               gt[i].domid,
                               gt[i].frame );  <--- So This sprintf doesn't make sence almost.
        }

        *eof = 1;
        return len;
}

Best Regards,

Akio Takebe

Quoted 7 lines

Hi, all

I think grant_read() is not runnable.
" (len > (PAGE_SIZE - 200)) " is not entered into if sentence becase of len=0.
So i always equal NR_GRANT_ENTRIES.

Quoted 7 lines

Is the below patch correct?
Please comment.

Best Regards,

Akio Takebe

This is patch for being able to read /proc/xen/grant.

linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c Wed Jan 25 17:01:03 2006 renamed from linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c Tue Jan 24 16:54:34 2006 +13 -13
diff -r a38c292e8390 linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c
@@ -361,22 +361,22 @@
        len = 0;
 
        for (i = 0; i < NR_GRANT_ENTRIES; i++) {
-               if (len > (PAGE_SIZE - 200)) {
+               if (len < (PAGE_SIZE - 200)) {
                        len += sprintf( page + len, "Truncated.\n");
                        break;
                }
-       }
-
-       if (gt[i].flags) {
-               len += sprintf(page + len,
-                              "Grant: ref (0x%x) flags (0x%hx) "
-                              "dom (0x%hx) frame (0x%x)\n", 
-                              i,
-                              gt[i].flags,
-                              gt[i].domid,
-                              gt[i].frame );
-       }
-
+
+               if (gt[i].flags) {
+                       len += sprintf(page + len,
+                                      "Grant: ref (0x%x) flags (0x%hx) "
+                                      "dom (0x%hx) frame (0x%x)\n", 
+                                      i,
+                                      gt[i].flags,
+                                      gt[i].domid,
+                                      gt[i].frame );
+               }
+
+       }
        *eof = 1;
        return len;
 }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel