免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: voidjackjiang
打印 上一主题 下一主题

g-bios command option auto-completion [复制链接]

论坛徽章:
0
11 [报告]
发表于 2010-09-30 19:53 |只看该作者
本帖最后由 jonny2010 于 2010-09-30 20:07 编辑

0001-g-bios-command-option-auto-completion.patch.tar.bz2 (4.15 KB, 下载次数: 6)

现在这个patch是基于git log中的5963c版本的g-bios;如果你是最新git下来的g-bios源码,若要打上此patch,请先使用如下步骤:
1、git log   (看看你git下来的是哪个版本的g-bios)
2、git reset --hard 5963c   (恢复到此5963c版本)
3、git am +patch-name


如此这样就可以打上patch了.....

论坛徽章:
0
12 [报告]
发表于 2010-10-08 17:03 |只看该作者
本帖最后由 cassel96 于 2010-10-08 17:05 编辑

大家打patch时候要注意,今天我们基于ef1c6f9e3798d967b358b1296b4d9345bebff61f这个版本重新打了patch
打patch时注意基于g-bios 5963c11ced71ef8ca32854c9e1c7702bba6bb5f0这个版本,还是ef1c6f9e3798d967b358b1296b4d9345bebff61f这个版本

论坛徽章:
0
13 [报告]
发表于 2010-10-08 21:28 |只看该作者
本帖最后由 jonny2010 于 2010-10-08 21:33 编辑

0000-g-bios-command-option-auto-complete.patch.tar.bz2 (3.51 KB, 下载次数: 5)
如楼上的所说,这个是基于ef1c6f9e3798d967b358b1296b4d9345bebff61f这个版本重新打的patch!
主要是修改了只能完全一起命令选项补齐的BUG,现在已经实现了能多个命令选项补齐的功能

论坛徽章:
0
14 [报告]
发表于 2010-10-08 22:20 |只看该作者
今天的工作主要是:
        1. 将之前在5963c版本完成的command option auto-completion的功能移植到ef1c版本上.
        2. fix命令选项不能多次补全的bug.
        3. 将没有选项的app的INSTALL_APLECATION($*, main, __app_option, NULL(或usr_opt_match))改为 INSTALL_APLECATION($*, main, NULL, NULL(或usr_opt_match)),并取消__app_option的定义.

明天计划:
        将ef1c版本中flash命令补全,子命令和命令选项补全移至flash.c中实现.

论坛徽章:
0
15 [报告]
发表于 2010-10-09 09:46 |只看该作者
1.现在的进展
    command option auto completion现在基本实现了命令参数补全包括多个参数补全功能,例如:ifconfig -l 192.168.0.100 -s,这个是可以补全的。
    我们现在是基于ef1c6f9e3798d967b358b1296b4d9345bebff61f这个版本的进行修改的,整合shell.c里面关于flash的代码,将我们以前的代码加进去,修改shell.c尽量不要和flash的代码冲突。
    将__app_option变成app_option,__usr_opt_match,变成usr_opt_match,前面加__这在内核里面表示内核调用,用户不要调用,而我们这里用户要调用,所以去掉__。
    节省空间,如果用户没有定义app_option二位数组,我们不给他定义一个空的,而是修改app.mk把INSTALL_APPLICATION($*, main, app_option, app_usr_opt_match);变成INSTALL_APPLICATION($*, main, NULL, app_usr_opt_match);

2.要做的工作
    将shell.c里面关于flash的代码移到flash相应的app文件中去。因为把flash的代码放在shell.c里面实在不妥。

3.在考虑的问题
   要不要加一个接口给app,使得他能自己实现命令补全,因为可能命令补全也有特殊情况,参数补全我们是提供了一个接口给app的。

论坛徽章:
0
16 [报告]
发表于 2010-10-09 12:31 |只看该作者
yes,just do it!

    我们就提供一个接口给app,让其能够实现自己定义的cmd_match。
    现在shell.c里面是有flash的代码的,这是别人的patch修改的,我认为这样是不妥的,shell.c里面为flash去写个subcmd_match,那是不是别的app也要在shell.c里面写subncmd_match函数呢?而且他们把arg_match也写在shell.c里面。
    所以现在我们提供两个接口给app,一个用于用户自己实现的命令补全,一个用于用户自己实现的参数补全。针对flash的就是他在shell.c里面写的subcmd_macth和arg_match。

论坛徽章:
0
17 [报告]
发表于 2010-10-09 12:48 |只看该作者
It is what l have done for the study during National Holiday below!

1:lmd study.

    For the first second day,l finished programming the lmd3 and lmd4 . Afther that, l did more some study with   the function of it  such as   alloc_chrdev_region and   register_chrdev_region function.

2:eglish study.

    L keeped reading english evry day till yestoday for the National Day and had gone over more than 120 pages of the book . For the recent days study , l had got more words and grammar  knowlege . l sure l would be more avalible for the work than beore.

3:did much more study with makeile and bash.

    L sought there was so much work to do with the makefile and bash, so l paid much attention to the g-bios's and linux-kernel's makefile study. After the study, l know more about the makefile     programming and  how the  makeile files in diffrent dirctory can organise and work together to make  g-bios work!

4:solved the left bug of the  command option  auto-complementation.

L didn't pay much enough attention to this part, but  with our team's work(mostlt done by my partners), we have fixed the bug  below:

bug1:
"g-bios#      ifconfi"

bug2:
"g-bios#ifconfig -l 192.168.0.1 -
    l    s    m    h    :    ?

bug3:
we have done some change to the  /built/rules/app.mk again to make the g-bios save more space!before this bug has been fixed,there are two words in evry application.c

static char __app_option[][CMD_OPTION_LEN] = {0};
INSTALL_APPLICATION(partshow, main, __app_option);

__app_option[][CMD_OPTION_LEN] is so large that we has changed it only to  "INSTALL_APPLICATION(partshow, main, NULL); " if __app_option has no value.So it can save a lot space!

论坛徽章:
0
18 [报告]
发表于 2010-10-10 12:21 |只看该作者
昨天主要是完成的工作:
1、把Flash的子命令匹配补全代码移植到flash.c里面
2、控制跳转到flash.c里面执行补全的判断条件,达到当子命令匹配完整,并且此时没有光标没有移动的时候,不会再进去flash.c里面执行子命令匹配的效果


遇到的问题:
移植的代码中,存在BUG,  不能实现真正的opt-auto-complete,只能是简单的以存在合法的  '-'  字符来作控制,只能显示存在的option,  不能补全!
原因是:代码中没有解析buf中‘-’之后的字符串是否合法,而且没有实现匹配,只是简单的显示效果而已!


解决方法:
在调试中。。。  最新动态会及时更新的!

论坛徽章:
0
19 [报告]
发表于 2010-10-12 09:56 |只看该作者
LDM5 STUDY:

Today we come to the ldm5,in the ldm5 the subsystem conception has been carried out ! The subsystem offers a general interface for the applications and low level drivers.When a application works, it calls the subsystem's general interface applications,and then the subsystem calls the functions(drivers) that you write.In the linux kernel almost every kind of devices has a corresponding subsystem.

There also is a subsystem in ldm5:

static struct file_operations file_operation = {
        .owner = THIS_MODULE,
        .open  = lmd5_open,
        .read  = lmd5_read,
        .write = lmd5_write,
        .release = lmd5_close,
};
static struct lmd_dev{
                dev_t dev_id;
                int (*open)(struct lmd_dev * lmd_dev);
                int (*close)(struct lmd_dev * lmd_dev);
                int (*read)(struct lmd_dev *, char *buff);
                int (*write)(struct lmd_dev *,const char *buff);
};
static int lmd5_open(struct inode * inodep, struct file * filep)
{
        struct lmd_dev *lmd = lmd_devs[iminor(inodep)];

        filep->private_data = lmd;

        printk("%s()\n", __FUNCTION__);
        return (lmd->open(lmd));
//        return 0;
}

When the application calls the open(....)  function, it will call the lmd5_open(....) which calls lmd->open(lmd) that you write in the drivers.

论坛徽章:
0
20 [报告]
发表于 2010-10-12 13:19 |只看该作者
调试过程中发现的问题:
1. 什么时候执行usr_cmd_match和usr_opt_match的问题
   之前的做法是:当用户输入tab键时,如果用户要补全的是命令,并且usr_cmd_match不为空,则执行usr_cmd_match。
   存在的问题是:当命令已经补全时,此时如果用户再输入tab键,用户要补全的是命令和usr_cmd_match不为空的条件依然成立,usr_cmd_match也就会再次被执行。
   解决办法:usr_cmd_match的返回值为匹配命令的个数。当返回值为1时,命令应经补全。当下次遇到tab键时,通过判断上一次的返回值来确定是否需要执行usr_cmd_match。

   对于usr_opt_match,做法、存在的问题和解决办法与以上所说的类似。不过,在flash.c的usr_opt_match中,只是简单的以存在 '-'  字符来作控制,只能显示存在的option,  不能补全!所以它的返回值永远都是选项的个数。个人认为,此函数是在shell.c提供好接口后,再根据接口实现usr_opt_match。不过现在的情况是usr_opt_match已经实现,且不符合shell.c所提供的接口。因此现在此问题还未解决。

2. flash子命令和命令选项补全移至flash.c中后,在编译的时候出现了一些warning,waring的主要内容是strcpy,strlen等字符串处理函数调用时参数类型和返回值类型不匹配。而我们检查并未发现有不匹配的情况。问题出在哪儿还需要仔细分析。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP