Re: [Yaffs] Re: Squelch mount-time debug messages by default

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Todd Poynor
Date:  
To: John M Cavallo
CC: yaffs
Old-Topics: [Yaffs] Re: Squelch mount-time debug messages by default
Subject: Re: [Yaffs] Re: Squelch mount-time debug messages by default
John M Cavallo wrote:
>> On Friday 04 November 2005 14:33, Todd Poynor wrote:
>>> Modify tracing of yaffs_GutsInitialise entry/exit messages from
>>> TRACE_ALWAYS to TRACE_TRACING (assuming this is an intended use of
>> that
>>> trace flag).
>> Thanx
>>
>> Will change this. The current flag usage is a bit unruly.
>>
>> I might concoct a better trace flag layout at some stage.
>>
>> BTW:
>>
>> Does anyone have a simple proc_write that could be hacked/patched
>> into
>> yaffsfs.c to allow the tracemask to be modified dynamically with
>> something
>> like:
>>
>>
>> # echo FFFFFFFF > /proc/yaffs
>>
>> ?
>>
>> -- Charles
>>
>
> Charles,
>
> I have two versions of this type of thing, one simple for the user the
> other simple for the programmer. I am attaching the latter. I find it
> easier because I can give it the logical name of the flag rather than
> it's bit position.
>
> In this one the flags can be set or cleared by echoing the name of the
> flag into /proc/yaffs with a '+' or '-':
>
> echo +os-write > /proc/yaffs
>
> It can be set to to all or none using '=', and then flags can be added
> or removed:
>
> echo =none+os+write > /proc/yaffs
>
> And you can use numerical values, if you are so inclined (using standard
> c format):
>
> echo 0xf00001 > /proc/yaffs
>
> It runs fine on my system, but when I went to add it to the latest
> version of Yaffs on the web (as of 9 Dec) I found some differences in
> other parts of the file that prevented compilation.
>
> Yeah, I might have gone overboard with this. If you want, I can clean up
> the other version and make it available as well.
>
> John
>
>
>
>
> ------------------------------------------------------------------------
>
> --- linux.orig/fs/yaffs2/yaffs_fs.c    2005-12-09 14:53:01.172020203 -0500
> +++ linux/fs/yaffs2/yaffs_fs.c    2005-12-09 15:00:21.941586939 -0500
> @@ -48,6 +48,7 @@
>  #include <linux/mtd/mtd.h>
>  #include <linux/interrupt.h>
>  #include <linux/string.h>
> +#include <linux/ctype.h>

>
> #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
>
> @@ -1675,6 +1676,120 @@
>      return buf - page < count ? buf - page : count;
>  }

>
> +/**
> + * Set the verbosity of the warnings and error messages.
> + *
> + */
> +
> +static struct {
> +    char *mask_name;
> +    unsigned mask_bitfield;
> +} mask_flags[] = {
> +    {"allocate", YAFFS_TRACE_ALLOCATE},
> +    {"always", YAFFS_TRACE_ALWAYS},
> +    {"bad_blocks", YAFFS_TRACE_BAD_BLOCKS},
> +    {"buffers", YAFFS_TRACE_BUFFERS},
> +    {"bug", YAFFS_TRACE_BUG},
> +    {"deletion", YAFFS_TRACE_DELETION},
> +    {"erase", YAFFS_TRACE_ERASE},
> +    {"error", YAFFS_TRACE_ERROR},
> +    {"gc_detail", YAFFS_TRACE_GC_DETAIL},
> +    {"gc", YAFFS_TRACE_GC},
> +    {"mtd", YAFFS_TRACE_MTD},
> +    {"nandaccess", YAFFS_TRACE_NANDACCESS},
> +    {"os", YAFFS_TRACE_OS},
> +    {"scan_debug", YAFFS_TRACE_SCAN_DEBUG},
> +    {"scan", YAFFS_TRACE_SCAN},
> +    {"tracing", YAFFS_TRACE_TRACING},
> +    {"write", YAFFS_TRACE_WRITE},
> +    {"all", 0xffffffff},
> +    {"none", 0},
> +    {NULL, 0},
> +};
> +
> +static int yaffs_proc_write(struct file *file, const char *buf,
> +                     unsigned long count, void *data)
> +{
> +    unsigned rg = 0, mask_bitfield;
> +    char *end, *mask_name;
> +    int i;
> +    int done = 0;
> +    int add, len;
> +    int pos = 0;
> +
> +    rg = yaffs_traceMask;
> +    
> +    while (!done && (pos < count)) {
> +        done = 1;
> +        while ((pos < count) && isspace(buf[pos])) {
> +            pos++;
> +        }
> +
> +        switch (buf[pos]) {
> +        case '+':
> +        case '-':
> +        case '=':
> +            add = buf[pos];
> +            pos++;
> +            break;
> +
> +        default:
> +            add = ' ';
> +            break;
> +        }
> +        mask_name = NULL;
> +        mask_bitfield = simple_strtoul(buf + pos, &end, 0);
> +        if (end > buf + pos) {
> +            mask_name = "numeral";
> +            len = end - (buf + pos);
> +            done = 0;
> +        } else {
> +
> +            for (i = 0; mask_flags[i].mask_name != NULL; i++) {
> +                len = strlen(mask_flags[i].mask_name);
> +                if (strncmp(buf + pos, mask_flags[i].mask_name, len) == 0) {
> +                    mask_name = mask_flags[i].mask_name;
> +                    mask_bitfield = mask_flags[i].mask_bitfield;
> +                    done = 0;
> +                    break;
> +                }
> +            }
> +        }
> +
> +        if (mask_name != NULL) {
> +                
> +            pos += len;
> +            done = 0;
> +            switch(add) {
> +            case '-':
> +                rg &= ~mask_bitfield;
> +                break;
> +            case '+':
> +                rg |= mask_bitfield;
> +                break;
> +            case '=':
> +                rg = mask_bitfield;
> +                break;
> +            default:
> +                rg |= mask_bitfield;
> +                break;
> +            }
> +        }
> +    }    
> +    // rg = simple_strtoul(buf, NULL, 0);
> +    yaffs_traceMask = rg;
> +    if (rg & YAFFS_TRACE_ALWAYS) {
> +        for (i = 0; mask_flags[i].mask_name != NULL; i++) {
> +            char flag;
> +            flag = ((rg & mask_flags[i].mask_bitfield) == mask_flags[i].mask_bitfield) ? '+' : '-';
> +            printk("%c%s\n", flag, mask_flags[i].mask_name);
> +        }
> +    }
> +    // printk("%08x\n", rg);
> +
> +    return count;
> +}
> +
>  /* Stuff to handle installation of file systems */
>  struct file_system_to_install {
>      struct file_system_type *fst;
> @@ -1700,11 +1815,15 @@
>        ("yaffs " __DATE__ " " __TIME__ " Installing. \n"));

>
>      /* Install the proc_fs entry */
> -    my_proc_entry = create_proc_read_entry("yaffs",
> +    my_proc_entry = create_proc_entry("yaffs",
>                             S_IRUGO | S_IFREG,
> -                           &proc_root,
> -                           yaffs_proc_read, NULL);
> -    if (!my_proc_entry) {
> +                           &proc_root);
> +
> +    if (my_proc_entry) {
> +        my_proc_entry->write_proc = yaffs_proc_write;
> +        my_proc_entry->read_proc = yaffs_proc_read;
> +        my_proc_entry->data = NULL;
> +    } else {
>          return -ENOMEM;
>      }


Committed this, thanks.

--
Todd