int test_yaffs_link_ENAMETOOLONG2(void) { int output=0; int error =0; int file_name_length=1000000; char file_name[file_name_length]; int x=0; for (x=0; x<file_name_length -1; x++){ file_name[x]='a'; } file_name[file_name_length-2]='\0'; output = yaffs_link(FILE_PATH,file_name); if (output<0){ error=yaffs_get_error(); if (abs(error)==ENAMETOOLONG){ return 1; } else { print_message("different error than expected\n",2); return -1; } } else { print_message("created a hard link with EROFS set (which is a bad thing)\n",2); return -1; } }
void link_test(const char *mountpt) { int i; int h; char a[100]; char b[100]; char c[100]; int f0; int f1; int f2; int f3; sprintf(a,"%s/aaa",mountpt); sprintf(b,"%s/bbb",mountpt); sprintf(c,"%s/ccc",mountpt); yaffs_StartUp(); yaffs_mount(mountpt); h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); for(i = 0; i < 100; i++) yaffs_write(h,a,100); yaffs_close(h); yaffs_unlink(b); yaffs_unlink(c); yaffs_link(a,b); yaffs_link(a,c); yaffs_unlink(b); yaffs_unlink(c); yaffs_unlink(a); yaffs_unmount(mountpt); yaffs_mount(mountpt); printf("link test done\n"); }
int test_yaffs_link_ENOENT4(void) { int output=0; int error =0; output = yaffs_link(DIR_PATH,HARD_LINK_PATH); if (output<0){ error=yaffs_get_error(); if (abs(error)==ENOENT){ return 1; } else { print_message("different error than expected\n",2); return -1; } } else { print_message("created a hard link to a dir (which is a bad thing)\n",2); return -1; } }
int test_yaffs_link_NULL2(void) { int output=0; int error =0; output = yaffs_link(FILE_PATH,NULL); if (output<0){ error=yaffs_get_error(); if (abs(error)==EFAULT){ return 1; } else { print_message("different error than expected\n",2); return -1; } } else { print_message("created a hard link to a non-existing-file (which is a bad thing)\n",2); return -1; } }
void link_test0(const char *mountpt) { char namea[300]; char nameb[300]; int result = 0; yaffs_StartUp(); yaffs_mount(mountpt); sprintf(namea,"%s/a",mountpt); sprintf(nameb,"%s/b",mountpt); printf("mounted\n"); dumpDir(mountpt); yaffs_unlink(namea); printf("a unlinked\n"); dumpDir(mountpt); yaffs_unlink(nameb); printf("b unlinked\n"); dumpDir(mountpt); result = yaffs_open(namea,O_CREAT| O_RDWR,0666); yaffs_close(result); printf("a created\n"); dumpDir(mountpt); yaffs_link(namea,nameb); printf("linked\n"); dumpDir(mountpt); yaffs_unlink(namea); printf("a ulinked\n"); dumpDir(mountpt); yaffs_unlink(nameb); printf("b unlinked\n"); dumpDir(mountpt); yaffs_unmount(mountpt); }
int test_yaffs_link_EROFS(void) { int output=0; int error =0; if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){ print_message("failed to create file\n",1); return -1; } EROFS_setup(); output = yaffs_link(FILE_PATH,HARD_LINK_PATH); if (output<0){ error=yaffs_get_error(); if (abs(error)==EROFS){ return 1; } else { print_message("different error than expected\n",2); return -1; } } else { print_message("created a hard link with EROFS set (which is a bad thing)\n",2); return -1; } }
static int __yaffs_link(mount_point_t *point, const char *path1, const char *path2) { return yaffs_link(vfs_path_add_mount_point(path1), vfs_path_add_mount_point(path2));