tftp 输出显示?

hc_net 2011-11-07 03:41:07
请教tftp 里的代码:
int filename_is_absolute;
int rc;

/* Construct URI */
uri = parse_uri ( filename );
if ( ! uri )
return -ENOMEM;
filename_is_absolute = uri_is_absolute ( uri );
uri_put ( uri );
if ( ! filename_is_absolute ) {
/* Construct a tftp:// URI for the filename. We can't
* just rely on the current working URI, because the
* relative URI resolution will remove the distinction
* between filenames with and without initial slashes,
* which is significant for TFTP.
*/
snprintf ( buf, sizeof ( buf ), "tftp://%s/",
inet_ntoa ( next_server ) );
uri_encode ( filename, buf + strlen ( buf ),
sizeof ( buf ) - strlen ( buf ), URI_PATH );
filename = buf;
}

image = alloc_image();
if ( ! image )
return -ENOMEM;
if ( ( rc = imgfetch ( image, filename,
register_and_autoload_image ) ) != 0 ) {
goto done;
}
if ( ( rc = imgexec ( image ) ) != 0 )
goto done;

done:
image_put ( image );
return rc;
}

/**
* Boot using root path
*
* @v root_path Root path
* @ret rc Return status code
*/
int boot_root_path ( const char *root_path ) {
struct sanboot_protocol *sanboot;

/* Quick hack */
for_each_table_entry ( sanboot, SANBOOT_PROTOCOLS ) {
if ( strncmp ( root_path, sanboot->prefix,
strlen ( sanboot->prefix ) ) == 0 ) {
return sanboot->boot ( root_path );
}
}

return -ENOTSUP;
}

/**
* Boot from a network device
*
* @v netdev Network device
* @ret rc Return status code
*/
static int netboot ( struct net_device *netdev ) {
struct setting vendor_class_id_setting
= { .tag = DHCP_VENDOR_CLASS_ID };
struct setting pxe_discovery_control_setting
= { .tag = DHCP_PXE_DISCOVERY_CONTROL };
struct setting pxe_boot_menu_setting
= { .tag = DHCP_PXE_BOOT_MENU };
char buf[256];
struct in_addr next_server;
unsigned int pxe_discovery_control;
int rc;

/* Open device and display device status */
if ( ( rc = ifopen ( netdev ) ) != 0 )
return rc;
ifstat ( netdev );

/* Configure device via DHCP */
if ( ( rc = dhcp ( netdev ) ) != 0 )
return rc;
route();

/* Try PXE menu boot, if applicable */
fetch_string_setting ( NULL, &vendor_class_id_setting,
buf, sizeof ( buf ) );
pxe_discovery_control =
fetch_uintz_setting ( NULL, &pxe_discovery_control_setting );
if ( ( strcmp ( buf, "PXEClient" ) == 0 ) &&
setting_exists ( NULL, &pxe_boot_menu_setting ) &&
( ! ( ( pxe_discovery_control & PXEBS_SKIP ) &&
setting_exists ( NULL, &filename_setting ) ) ) ) {
printf ( "Booting from PXE menu\n" );
return pxe_menu_boot ( netdev );
}

/* Try to download and boot whatever we are given as a filename */
fetch_ipv4_setting ( NULL, &next_server_setting, &next_server );
fetch_string_setting ( NULL, &filename_setting, buf, sizeof ( buf ) );
if ( buf[0] ) {
printf ( "Booting from filename \"%s\"\n", buf );
if ( ( rc = boot_next_server_and_filename ( next_server,
buf ) ) != 0 ) {
printf ( "Could not boot from filename \"%s\": %s\n",
buf, strerror ( rc ) );
return rc;
}
return 0;
}

/* No filename; try the root path */
fetch_string_setting ( NULL, &root_path_setting, buf, sizeof ( buf ) );
if ( buf[0] ) {
printf ( "Booting from root path \"%s\"\n", buf );
if ( ( rc = boot_root_path ( buf ) ) != 0 ) {
printf ( "Could not boot from root path \"%s\": %s\n",
buf, strerror ( rc ) );
return rc;
}
return 0;
}

printf ( "No filename or root path specified\n" );
return -ENOENT;
}



输出格式为:tftp://192.168.0.252/pxelinux.0

snprintf ( buf, sizeof ( buf ), "tftp://%s/",
inet_ntoa ( next_server ) );
uri_encode ( filename, buf + strlen ( buf ),
sizeof ( buf ) - strlen ( buf ), URI_PATH );

如何修改以上代码:不打印显示输出 tftp 路径到屏幕上。

谢谢
...全文
85 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hc_net 2011-11-07
  • 打赏
  • 举报
回复
buf[0]=0; 这个试过了编译不通
赵4老师 2011-11-07
  • 打赏
  • 举报
回复
/*snprintf ( buf, sizeof ( buf ), "tftp://%s/",
inet_ntoa ( next_server ) );*/ buf[0]=0;
试试
luciferisnotsatan 2011-11-07
  • 打赏
  • 举报
回复
把printf 语句去了,或者输出重定向不就行了

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧