]> err.no Git - linux-2.6/blobdiff - drivers/block/genhd.c
[PATCH] Clean up struct flock64 definitions
[linux-2.6] / drivers / block / genhd.c
index 43805e4d31e965991f64c1a0fbb67f30e26a6140..d42840cc0d1dfcd0fad18fca25041c04ac69661a 100644 (file)
@@ -40,19 +40,27 @@ static inline int major_to_index(int major)
 
 #ifdef CONFIG_PROC_FS
 /* get block device names in somewhat random order */
-int get_blkdev_list(char *p)
+int get_blkdev_list(char *p, int used)
 {
        struct blk_major_name *n;
        int i, len;
 
-       len = sprintf(p, "\nBlock devices:\n");
+       len = snprintf(p, (PAGE_SIZE-used), "\nBlock devices:\n");
 
        down(&block_subsys_sem);
        for (i = 0; i < ARRAY_SIZE(major_names); i++) {
-               for (n = major_names[i]; n; n = n->next)
+               for (n = major_names[i]; n; n = n->next) {
+                       /*
+                        * If the curent string plus the 5 extra characters
+                        * in the line would run us off the page, then we're done
+                        */
+                       if ((len + used + strlen(n->name) + 5) >= PAGE_SIZE)
+                               goto page_full;
                        len += sprintf(p+len, "%3d %s\n",
                                       n->major, n->name);
+               }
        }
+page_full:
        up(&block_subsys_sem);
 
        return len;