void nfs_start(void) { nfs_init(); if (dfs_mount(RT_NULL, "/nfs", "nfs", 0, RT_NFS_HOST_EXPORT) == 0) { rt_kprintf("NFSv3 File System initialized!\n"); } else rt_kprintf("NFSv3 File System initialzation failed!\n"); }
void network_init(void) { printf("\nStarting %s\n", __FUNCTION__); // Initialise the nslu2 hardware ixOsalOemInit(); /* Initialise lwIP */ mem_init(); memp_init(); pbuf_init(); netif_init(); udp_init(); etharp_init(); /* Setup the network interface */ struct ip_addr netmask, ipaddr, gw; IP4_ADDR(&netmask, 255, 255, 255, 0); // Standard net mask IP4_ADDR(&gw, 192, 168, 0, 1); // Your host system IP4_ADDR(&ipaddr, 192, 168, 0, 2); // The Slug's IP address struct netif *netif = netif_add(&ipaddr,&netmask,&gw, sosIfInit, ip_input); netif_set_default(netif); // Generate an arp entry for our gateway // We should only need to do this once, but Linux seems to love ignoring // ARP queries (why??!), so we keep trying until we get a response struct pbuf *p = etharp_query(netif, &netif->gw, NULL); do { (*netif_default->linkoutput)(netif, p); // Direct output sos_usleep(100000); // Wait a while for a reply } while (!etharp_entry_present(&netif->gw)); pbuf_free(p); // Finish the initialisation of the nslu2 hardware ixOsalOSServicesFinaliseInit(); /* Initialise NFS */ int r = nfs_init(gw); assert(!r); mnt_get_export_list(); // Print out the exports on this server const char *msg; if (mnt_mount(NFS_DIR, &mnt_point)) // Mount aos_nfs msg = "%s: Error mounting path '%s'!\n"; else msg = "Successfully mounted '%s'\n"; printf(msg, __FUNCTION__, NFS_DIR); printf("Finished %s\n\n", __FUNCTION__); }
/* * Initialize. * Returns: 0 if OK, non-zero (errno) if failed. */ static int amfs_nfsl_init(mntfs *mf) { /* * If a link, do nothing (same as type:=link). * If non-link, do nfs_init (same as type:=nfs). */ if (mf->mf_flags & MFF_NFSLINK) { return 0; } else { return nfs_init(mf); } }
int main(int argc, char *argv[]) { struct addrinfo *srv_addr, hints; int err; enum clnt_stat stat; nfs_ctx *ctx = NULL; if(argc < 2) { fprintf(stderr, "Not enough arguments\nThis tests the asynchronous " "libnfsclient MOUNT DUMP call interface and " "callback\n" "USAGE: nfs_mnt_dump <server>\n"); return 0; } /* First resolve server name */ hints.ai_family = AF_INET; hints.ai_protocol = 0; hints.ai_socktype = 0; hints.ai_flags = 0; fprintf(stdout, "Resolving name %s\n", argv[1]); if((err = getaddrinfo(argv[1], NULL, &hints, &srv_addr)) != 0) { fprintf(stderr, "Cannot resolve name: %s\n", gai_strerror(err)); return -1; } fprintf(stdout, "Creating NFS client context\n"); ctx = nfs_init((struct sockaddr_in *)srv_addr->ai_addr, IPPROTO_TCP, 0); if(ctx == NULL) { fprintf(stderr, "Cant init nfs context\n"); return 0; } fprintf(stdout, "Sending mount dump call\n"); stat = mount3_dump(ctx, mnt_dump_cb, NULL); if(stat == RPC_SUCCESS) fprintf(stderr, "MOUNT DUMP Call sent successfully\n"); else fprintf(stderr, "Could not send MOUNT NULL call\n"); return 0; }
/** * RT-Thread Components Initialization */ void rt_components_init(void) { #ifndef _MSC_VER #ifdef RT_DEBUG_INIT int result; const struct rt_init_desc *desc; rt_kprintf("do components intialization.\n"); for (desc = &__rt_init_desc_rti_board_end; desc < &__rt_init_desc_rti_end; desc ++) { rt_kprintf("initialize %s", desc->fn_name); result = desc->fn(); rt_kprintf(":%d done\n", result); } #else const init_fn_t *fn_ptr; for (fn_ptr = &__rt_init_rti_board_end; fn_ptr < &__rt_init_rti_end; fn_ptr ++) { (*fn_ptr)(); } #endif #else #ifdef RT_USING_MODULE rt_system_module_init(); #endif #ifdef RT_USING_FINSH /* initialize finsh */ finsh_system_init(); finsh_set_device(RT_CONSOLE_DEVICE_NAME); #endif #ifdef RT_USING_LWIP /* initialize lwip stack */ /* register ethernetif device */ eth_system_device_init(); /* initialize lwip system */ lwip_system_init(); rt_kprintf("TCP/IP initialized!\n"); #endif #ifdef RT_USING_DFS /* initialize the device file system */ dfs_init(); #ifdef RT_USING_DFS_ELMFAT /* initialize the elm chan FatFS file system*/ elm_init(); #endif #if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP) /* initialize NFSv3 client file system */ nfs_init(); #endif #ifdef RT_USING_DFS_YAFFS2 dfs_yaffs2_init(); #endif #ifdef RT_USING_DFS_UFFS dfs_uffs_init(); #endif #ifdef RT_USING_DFS_JFFS2 dfs_jffs2_init(); #endif #ifdef RT_USING_DFS_ROMFS dfs_romfs_init(); #endif #ifdef RT_USING_DFS_RAMFS dfs_ramfs_init(); #endif #ifdef RT_USING_DFS_DEVFS devfs_init(); #endif #endif /* end of RT_USING_DFS */ #ifdef RT_USING_NEWLIB libc_system_init(RT_CONSOLE_DEVICE_NAME); #else /* the pthread system initialization will be initiallized in libc */ #ifdef RT_USING_PTHREADS pthread_system_init(); #endif #endif #ifdef RT_USING_RTGUI rtgui_system_server_init(); #endif #ifdef RT_USING_USB_HOST rt_usb_host_init(); #endif #endif }
int main(int argc, char *argv[]) { struct addrinfo *srv_addr, hints; int err; enum clnt_stat stat; nfs_ctx *ctx = NULL; FSSTAT3args fs; if(argc < 3) { fprintf(stderr, "Not enough arguments\nThis tests the asynchronous " "libnfsclient NFS FSSTAT call interface and " "callback\n" "USAGE: nfs_fsstat <server> <remote_file_dir>\n"); return 0; } /* First resolve server name */ hints.ai_family = AF_INET; hints.ai_protocol = 0; hints.ai_socktype = 0; hints.ai_flags = 0; fprintf(stdout, "Resolving name %s\n", argv[1]); if((err = getaddrinfo(argv[1], NULL, &hints, &srv_addr)) != 0) { fprintf(stderr, "%s: Cannot resolve name: %s: %s\n", argv[0], argv[1], gai_strerror(err)); return -1; } fprintf(stdout, "Creating nfs client context..\n"); ctx = nfs_init((struct sockaddr_in *)srv_addr->ai_addr, IPPROTO_TCP, 0); if(ctx == NULL) { fprintf(stderr, "%s: Cant init nfs context\n", argv[0]); return 0; } freeaddrinfo(srv_addr); mntfh.fhandle3_len = 0; fprintf(stdout, "Sending mount call..\n"); stat = mount3_mnt(&argv[2], ctx, nfs_mnt_cb, NULL); if(stat == RPC_SUCCESS) fprintf(stderr, "NFS MOUNT Call sent successfully\n"); else { fprintf(stderr, "Could not send NFS MOUNT call\n"); return 0; } fs.fsroot.data.data_len = mntfh.fhandle3_len; fs.fsroot.data.data_val = mntfh.fhandle3_val; fprintf(stdout, "Sending fsstat call..\n"); stat = nfs3_fsstat(&fs, ctx, nfs_fsstat_cb, NULL); if(stat == RPC_SUCCESS) fprintf(stderr, "NFS FSSTAT Call sent successfully\n"); else { fprintf(stderr, "Could not send NFS FSSTAT call\n"); return 0; } fprintf(stdout, "Waiting for fsstat reply..\n"); nfs_complete(ctx, RPC_BLOCKING_WAIT); fprintf(stdout, "Fsstat reply received..\n"); return 0; }
int main(int argc, char *argv[]) { struct addrinfo *srv_addr, hints; int err; enum clnt_stat stat; nfs_ctx *ctx = NULL; SYMLINK3args sym; if(argc < 5) { fprintf(stderr, "Not enough arguments\nThis tests the asynchronous " "libnfsclient NFS SYMLINK call interface and " "callback\n" "USAGE: nfs_symlink <server> <remote_file_dir> " "<linkname> <target>\n"); return 0; } /* First resolve server name */ hints.ai_family = AF_INET; hints.ai_protocol = 0; hints.ai_socktype = 0; hints.ai_flags = 0; fprintf(stdout, "Resolving name %s\n", argv[1]); if((err = getaddrinfo(argv[1], NULL, &hints, &srv_addr)) != 0) { fprintf(stderr, "%s: Cannot resolve name: %s: %s\n", argv[0], argv[1], gai_strerror(err)); return -1; } fprintf(stdout, "Creating nfs client context..\n"); ctx = nfs_init((struct sockaddr_in *)srv_addr->ai_addr, IPPROTO_TCP, 0); if(ctx == NULL) { fprintf(stderr, "%s: Cant init nfs context\n", argv[0]); return 0; } freeaddrinfo(srv_addr); mntfh.fhandle3_len = 0; fprintf(stdout, "Sending mount call..\n"); stat = mount3_mnt(&argv[2], ctx, nfs_mnt_cb, NULL); if(stat == RPC_SUCCESS) fprintf(stderr, "NFS MOUNT Call sent successfully\n"); else { fprintf(stderr, "Could not send NFS MOUNT call\n"); return 0; } sym.where.name = argv[3]; sym.where.dir.data.data_len = mntfh.fhandle3_len; sym.where.dir.data.data_val = mntfh.fhandle3_val; sym.symlink.symlink_data = argv[4]; memset(&sym.symlink.symlink_attributes, 0, sizeof(sattr3)); sym.symlink.symlink_attributes.mode.set_it = 1; sym.symlink.symlink_attributes.uid.set_it = 1; sym.symlink.symlink_attributes.gid.set_it = 1; sym.symlink.symlink_attributes.size.set_it = 1; sym.symlink.symlink_attributes.atime.set_it = 1; sym.symlink.symlink_attributes.mtime.set_it = 1; fprintf(stdout, "Sending symlink call..\n"); stat = nfs3_symlink(&sym, ctx, nfs_symlink_cb, NULL); if(stat == RPC_SUCCESS) fprintf(stderr, "NFS SYMLINK Call sent successfully\n"); else { fprintf(stderr, "Could not send NFS SYMLINK call\n"); return 0; } fprintf(stdout, "Waiting for symlink reply..\n"); nfs_complete(ctx, RPC_BLOCKING_WAIT); return 0; }
/** * RT-Thread Components Initialization */ void rt_components_init(void) { #ifdef RT_USING_MODULE rt_system_module_init(); #endif #ifdef RT_USING_FINSH /* initialize finsh */ finsh_system_init(); finsh_set_device(RT_CONSOLE_DEVICE_NAME); #endif #ifdef RT_USING_LWIP /* initialize lwip stack */ /* register ethernetif device */ eth_system_device_init(); /* initialize lwip system */ lwip_system_init(); rt_kprintf("TCP/IP initialized!\n"); #endif #ifdef RT_USING_DFS /* initialize the device file system */ dfs_init(); #ifdef RT_USING_DFS_ELMFAT /* initialize the elm chan FatFS file system*/ elm_init(); #endif #if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP) /* initialize NFSv3 client file system */ nfs_init(); #endif #ifdef RT_USING_DFS_YAFFS2 dfs_yaffs2_init(); #endif #ifdef RT_USING_DFS_UFFS dfs_uffs_init(); #endif #ifdef RT_USING_DFS_JFFS2 dfs_jffs2_init(); #endif #ifdef RT_USING_DFS_ROMFS dfs_romfs_init(); #endif #ifdef RT_USING_DFS_DEVFS devfs_init(); #endif #endif /* end of RT_USING_DFS */ #ifdef RT_USING_NEWLIB libc_system_init(RT_CONSOLE_DEVICE_NAME); #else /* the pthread system initialization will be initiallized in libc */ #ifdef RT_USING_PTHREADS pthread_system_init(); #endif #endif #ifdef RT_USING_RTGUI rtgui_system_server_init(); #endif #ifdef RT_USING_USB_HOST rt_usb_host_init(); #endif return; }
void rt_init_thread_entry(void *parameter) { /* Filesystem Initialization */ #ifdef RT_USING_DFS { /* init the device filesystem */ dfs_init(); #if defined(RT_USING_DFS_ELMFAT) /* init the elm chan FatFs filesystam*/ elm_init(); /* mount sd card fat partition 1 as root directory */ if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) { rt_kprintf("File System initialized!\n"); } else rt_kprintf("File System initialzation failed!\n"); #endif #if defined(RT_USING_DFS_ROMFS) dfs_romfs_init(); if (dfs_mount(RT_NULL, "/rom", "rom", 0, &romfs_root) == 0) { rt_kprintf("ROM File System initialized!\n"); } else rt_kprintf("ROM File System initialzation failed!\n"); #endif #if defined(RT_USING_DFS_DEVFS) devfs_init(); if (dfs_mount(RT_NULL, "/dev", "devfs", 0, 0) == 0) rt_kprintf("Device File System initialized!\n"); else rt_kprintf("Device File System initialzation failed!\n"); #ifdef RT_USING_NEWLIB /* init libc */ libc_system_init("uart0"); #endif #endif #if defined(RT_USING_DFS) && defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS) /* NFSv3 Initialization */ nfs_init(); if (dfs_mount(RT_NULL, "/nfs", "nfs", 0, RT_NFS_HOST_EXPORT) == 0) rt_kprintf("NFSv3 File System initialized!\n"); else rt_kprintf("NFSv3 File System initialzation failed!\n"); #endif #if defined(RT_USING_DFS_UFFS) /* init the uffs filesystem */ dfs_uffs_init(); /* mount flash device as flash directory */ if (dfs_mount("nand0", "/nand0", "uffs", 0, 0) == 0) rt_kprintf("UFFS File System initialized!\n"); else rt_kprintf("UFFS File System initialzation failed!\n"); #endif } #endif #ifdef RT_USING_RTGUI { extern void rtgui_system_server_init(void); rt_device_t lcd; /* init lcd */ rt_hw_lcd_init(); /* init touch panel */ rtgui_touch_hw_init(); /* init keypad */ rt_hw_key_init(); /* find lcd device */ lcd = rt_device_find("lcd"); /* set lcd device as rtgui graphic driver */ rtgui_graphic_set_device(lcd); /* initalize rtgui system server */ rtgui_system_server_init(); } #endif /* LwIP Initialization */ #ifdef RT_USING_LWIP { extern void lwip_sys_init(void); eth_system_device_init(); /* register ethernetif device */ rt_hw_dm9000_init(); /* init lwip system */ lwip_sys_init(); rt_kprintf("TCP/IP initialized!\n"); } #endif #ifdef RT_USING_FTK { rt_thread_t ftk_thread; /* init lcd */ rt_hw_lcd_init(); /* init touch panel */ rtgui_touch_hw_init(); /* init keypad */ rt_hw_key_init(); /* create ftk thread */ ftk_thread = rt_thread_create("ftk", rt_ftk_thread_entry, RT_NULL, 10 * 1024, 8, 20); /* startup ftk thread */ if (ftk_thread != RT_NULL) rt_thread_startup(ftk_thread); } #endif }
/** * RT-Thread Components Initialization */ void rt_components_init(void) { #ifdef RT_USING_MODULE rt_system_module_init(); #endif #ifdef RT_USING_FINSH /* initialize finsh */ finsh_system_init(); finsh_set_device(RT_CONSOLE_DEVICE_NAME); #endif #ifdef RT_USING_LWIP /* initialize lwip stack */ /* register ethernetif device */ eth_system_device_init(); /* initialize lwip system */ lwip_system_init(); rt_kprintf("TCP/IP initialized!\n"); #endif #ifdef RT_USING_DFS /* initialize the device file system */ dfs_init(); #ifdef RT_USING_DFS_ELMFAT /* initialize the elm chan FatFS file systam*/ elm_init(); #endif #if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP) extern void nfs_init(void); /* initialize NFSv3 client file system */ nfs_init(); #endif #ifdef RT_USING_DFS_YAFFS2 yaffs2_init(); #endif #ifdef RT_USING_DFS_UFFS uffs_init(); #endif #ifdef RT_USING_DFS_JFFS2 jffs2_init(); #endif #ifdef RT_USING_DFS_ROMFS romfs_init(); #endif #ifdef RT_USING_DFS_DEVFS devfs_init(); #endif #endif #ifdef RT_USING_NEWLIB libc_system_init(RT_CONSOLE_DEVICE_NAME); #endif #ifdef RT_USING_PTHREADS pthread_system_init(); #endif #ifdef RT_USING_RTGUI rtgui_system_server_init(); #endif return; }
int main(int argc, char *argv[]) { struct addrinfo *srv_addr, hints; int err; enum clnt_stat stat; nfs_ctx *ctx = NULL; LOOKUP3args largs; READDIRPLUS3args rdirp; if(argc < 4) { fprintf(stderr, "Not enough arguments\nThis tests the asynchronous " "libnfsclient NFS READDIRPLUS call interface and " "callback\n" "USAGE: nfs_readdirplus <server> <remote_file_dir> " "<dirname>\n"); return 0; } /* First resolve server name */ hints.ai_family = AF_INET; hints.ai_protocol = 0; hints.ai_socktype = 0; hints.ai_flags = 0; fprintf(stdout, "Resolving name %s\n", argv[1]); if((err = getaddrinfo(argv[1], NULL, &hints, &srv_addr)) != 0) { fprintf(stderr, "%s: Cannot resolve name: %s: %s\n", argv[0], argv[1], gai_strerror(err)); return -1; } fprintf(stdout, "Creating client nfs context..\n"); ctx = nfs_init((struct sockaddr_in *)srv_addr->ai_addr, IPPROTO_TCP, 0); if(ctx == NULL) { fprintf(stderr, "%s: Cant init nfs context\n", argv[0]); return 0; } freeaddrinfo(srv_addr); mntfh.fhandle3_len = 0; fprintf(stdout, "Sending mount call..\n"); stat = mount3_mnt(&argv[2], ctx, nfs_mnt_cb, NULL); if(stat == RPC_SUCCESS) fprintf(stderr, "NFS MOUNT Call sent successfully\n"); else { fprintf(stderr, "Could not send NFS MOUNT call\n"); return 0; } largs.what.dir.data.data_len = mntfh.fhandle3_len; largs.what.dir.data.data_val = mntfh.fhandle3_val; largs.what.name = argv[3]; lfh.fhandle3_len = 0; fprintf(stdout, "Sending lookup call..\n"); stat = nfs3_lookup(&largs, ctx, nfs_lookup_cb, NULL); if(stat == RPC_SUCCESS) fprintf(stderr, "NFS LOOKUP Call sent successfully\n"); else { fprintf(stderr, "Could not send NFS LOOKUP call\n"); return 0; } fprintf(stdout, "Waiting for lookup reply..\n"); nfs_complete(ctx, RPC_BLOCKING_WAIT); fprintf(stdout, "Lookup reply received..\n"); rdirp.dir.data.data_len = lfh.fhandle3_len; rdirp.dir.data.data_val = lfh.fhandle3_val; rdirp.cookie = 0; memset(&rdirp.cookieverf, 0, NFS3_COOKIEVERFSIZE); rdirp.dircount = 20; rdirp.maxcount = 2048; fprintf(stdout, "Sending readdirplus call..\n"); stat = nfs3_readdirplus(&rdirp, ctx, nfs_readdirplus_cb, NULL); if(stat == RPC_SUCCESS) fprintf(stderr, "NFS READDIRPLUS Call sent successfully\n"); else { fprintf(stderr, "Could not send NFS READDIRPLUS call\n"); return 0; } free_LOOKUP3res(lookupres); fprintf(stdout, "Waiting for readdirplus reply..\n"); nfs_complete(ctx, RPC_BLOCKING_WAIT); fprintf(stdout, "Readdirplus reply received..\n"); return 0; }
int main(int argc, char *argv[]) { struct addrinfo *srv_addr, hints; int err; enum clnt_stat stat; nfs_ctx *ctx = NULL; LOOKUP3args largs; WRITE3args wr; COMMIT3args ci; if(argc < 6) { fprintf(stderr, "Not enough arguments\nThis tests the asynchronous " "libnfsclient NFS WRITE call interface and " "callback\n" "USAGE: nfs_write <server> <remote_file_dir> " "<file/dirname> <offset> <count>\n" "NOTE: <count> is ignored for now.\n"); return 0; } /* First resolve server name */ hints.ai_family = AF_INET; hints.ai_protocol = 0; hints.ai_socktype = 0; hints.ai_flags = 0; fprintf(stdout, "Resolving name: %s\n", argv[1]); if((err = getaddrinfo(argv[1], NULL, &hints, &srv_addr)) != 0) { fprintf(stderr, "%s: Cannot resolve name: %s: %s\n", argv[0], argv[1], gai_strerror(err)); return -1; } fprintf(stdout, "Creating nfs client context..\n"); ctx = nfs_init((struct sockaddr_in *)srv_addr->ai_addr, IPPROTO_TCP, 0); if(ctx == NULL) { fprintf(stderr, "%s: Cant init nfs context\n", argv[0]); return 0; } freeaddrinfo(srv_addr); mntfh.fhandle3_len = 0; fprintf(stdout, "Sending mount call..\n"); stat = mount3_mnt(&argv[2], ctx, nfs_mnt_cb, NULL); if(stat == RPC_SUCCESS) fprintf(stderr, "NFS MOUNT Call sent successfully\n"); else { fprintf(stderr, "Could not send NFS MOUNT call\n"); return 0; } fprintf(stdout, "Mount call received..\n"); largs.what.dir.data.data_len = mntfh.fhandle3_len; largs.what.dir.data.data_val = mntfh.fhandle3_val; largs.what.name = argv[3]; lfh.fhandle3_len = 0; fprintf(stdout, "Sending lookup call for %s\n", argv[3]); stat = nfs3_lookup(&largs, ctx, nfs_lookup_cb, NULL); if(stat == RPC_SUCCESS) fprintf(stderr, "NFS LOOKUP Call sent successfully\n"); else { fprintf(stderr, "Could not send NFS LOOKUP call\n"); return 0; } /* Dont need the mount file handle anymore. */ mem_free(mntfh.fhandle3_val, mntfh.fhandle3_len); fprintf(stdout, "Waiting for lookup reply..\n"); nfs_complete(ctx, RPC_BLOCKING_WAIT); fprintf(stdout, "Lookup reply received..\n"); wr.file.data.data_len = lfh.fhandle3_len; wr.file.data.data_val = lfh.fhandle3_val; wr.offset = atol(argv[4]); wr.count = strlen(wrdat); //wr.count = atol(argv[5]); wr.stable = UNSTABLE; wr.data.data_len = strlen(wrdat); wr.data.data_val = wrdat; res = NULL; fprintf(stdout, "Sending write call\n"); stat = nfs3_write(&wr, ctx, nfs_write_cb, NULL); if(stat == RPC_SUCCESS) fprintf(stderr, "NFS WRITE Call sent successfully\n"); else { fprintf(stderr, "Could not send NFS WRITE call\n"); return 0; } fprintf(stdout, "Waiting for write reply..\n"); nfs_complete(ctx, RPC_BLOCKING_WAIT); free_WRITE3res(res); fprintf(stdout, "Write reply received..\n"); ci.file.data.data_len = lfh.fhandle3_len; ci.file.data.data_val = lfh.fhandle3_val; ci.offset = atol(argv[4]); ci.count = strlen(wrdat); fprintf(stdout, "Sending commit request..\n"); stat = nfs3_commit(&ci, ctx, nfs_commit_cb, NULL); if(stat == RPC_SUCCESS) fprintf(stderr, "NFS COMMIT Call sent successfully\n"); else { fprintf(stderr, "Could not send NFS COMMIT call\n"); return 0; } fprintf(stdout, "Waiting for commit reply..\n"); nfs_complete(ctx, RPC_BLOCKING_WAIT); fprintf(stdout, "Received commit reply..\n"); return 0; }