" device type 'interface' instance 'dev'."
)
+static int do_ln_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ return do_ln(cmdtp, flag, argc, argv, FS_TYPE_ANY);
+}
+
+U_BOOT_CMD(
+ ln, 5, 1, do_ln_wrapper,
+ "Create a symbolic link",
+ "<interface> <dev[:part]> target linkname\n"
+ " - create a symbolic link to 'target' with the name 'linkname' on\n"
+ " device type 'interface' instance 'dev'."
+)
+
static int do_fstype_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
return -1;
}
+static inline int fs_ln_unsupported(const char *filename, const char *target)
+{
+ return -1;
+}
+
static inline void fs_close_unsupported(void)
{
}
void (*closedir)(struct fs_dir_stream *dirs);
int (*unlink)(const char *filename);
int (*mkdir)(const char *dirname);
+ int (*ln)(const char *filename, const char *target);
};
static struct fstype_info fstypes[] = {
.opendir = fat_opendir,
.readdir = fat_readdir,
.closedir = fat_closedir,
+ .ln = fs_ln_unsupported,
},
#endif
.read = ext4_read_file,
#ifdef CONFIG_CMD_EXT4_WRITE
.write = ext4_write_file,
+ .ln = ext4fs_create_link,
#else
.write = fs_write_unsupported,
+ .ln = fs_ln_unsupported,
#endif
.uuid = ext4fs_uuid,
.opendir = fs_opendir_unsupported,
.opendir = fs_opendir_unsupported,
.unlink = fs_unlink_unsupported,
.mkdir = fs_mkdir_unsupported,
+ .ln = fs_ln_unsupported,
},
#endif
#ifdef CONFIG_CMD_UBIFS
.opendir = fs_opendir_unsupported,
.unlink = fs_unlink_unsupported,
.mkdir = fs_mkdir_unsupported,
+ .ln = fs_ln_unsupported,
},
#endif
#ifdef CONFIG_FS_BTRFS
.opendir = fs_opendir_unsupported,
.unlink = fs_unlink_unsupported,
.mkdir = fs_mkdir_unsupported,
+ .ln = fs_ln_unsupported,
},
#endif
{
.opendir = fs_opendir_unsupported,
.unlink = fs_unlink_unsupported,
.mkdir = fs_mkdir_unsupported,
+ .ln = fs_ln_unsupported,
},
};
return ret;
}
+int fs_ln(const char *fname, const char *target)
+{
+ struct fstype_info *info = fs_get_info(fs_type);
+ int ret;
+
+ ret = info->ln(fname, target);
+
+ if (ret < 0) {
+ printf("** Unable to create link %s -> %s **\n", fname, target);
+ ret = -1;
+ }
+ fs_close();
+
+ return ret;
+}
+
int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
int fstype)
{
return 0;
}
+
+int do_ln(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
+ int fstype)
+{
+ if (argc != 5)
+ return CMD_RET_USAGE;
+
+ if (fs_set_blk_dev(argv[1], argv[2], fstype))
+ return 1;
+
+ if (fs_ln(argv[3], argv[4]))
+ return 1;
+
+ return 0;
+}