Changeset db9c889 in mainline for uspace/lib
- Timestamp:
- 2018-06-29T13:22:39Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 72c72d4
- Parents:
- 5f36841
- git-author:
- Jiri Svoboda <jiri@…> (2018-06-28 17:22:13)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-06-29 13:22:39)
- Location:
- uspace/lib
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
r5f36841 rdb9c889 112 112 generic/io/log.c \ 113 113 generic/io/logctl.c \ 114 generic/io/label.c \ 114 115 generic/io/kio.c \ 115 116 generic/io/klog.c \ -
uspace/lib/c/generic/vol.c
r5f36841 rdb9c889 304 304 } 305 305 306 /** Format file system type as string. 307 * 308 * @param fstype File system type 309 * @param rstr Place to store pointer to newly allocated string 310 * @return EOK on success, ENOMEM if out of memory 311 */ 312 errno_t vol_fstype_format(vol_fstype_t fstype, char **rstr) 313 { 314 const char *sfstype; 315 char *s; 316 317 sfstype = NULL; 318 switch (fstype) { 319 case fs_exfat: 320 sfstype = "ExFAT"; 321 break; 322 case fs_fat: 323 sfstype = "FAT"; 324 break; 325 case fs_minix: 326 sfstype = "MINIX"; 327 break; 328 case fs_ext4: 329 sfstype = "Ext4"; 330 break; 331 case fs_cdfs: 332 sfstype = "ISO 9660"; 333 break; 334 } 335 336 s = str_dup(sfstype); 337 if (s == NULL) 338 return ENOMEM; 339 340 *rstr = s; 341 return EOK; 342 } 343 344 /** Format partition content / file system type as string. 345 * 346 * @param pcnt Partition content 347 * @param fstype File system type 348 * @param rstr Place to store pointer to newly allocated string 349 * @return EOK on success, ENOMEM if out of memory 350 */ 351 errno_t vol_pcnt_fs_format(vol_part_cnt_t pcnt, vol_fstype_t fstype, 352 char **rstr) 353 { 354 int rc; 355 char *s = NULL; 356 357 switch (pcnt) { 358 case vpc_empty: 359 s = str_dup("Empty"); 360 if (s == NULL) 361 return ENOMEM; 362 break; 363 case vpc_fs: 364 rc = vol_fstype_format(fstype, &s); 365 if (rc != EOK) 366 return ENOMEM; 367 break; 368 case vpc_unknown: 369 s = str_dup("Unknown"); 370 if (s == NULL) 371 return ENOMEM; 372 break; 373 } 374 375 assert(s != NULL); 376 *rstr = s; 377 return EOK; 378 } 379 306 380 /** @} 307 381 */ -
uspace/lib/c/include/types/vol.h
r5f36841 rdb9c889 37 37 38 38 #include <async.h> 39 #include <ipc/vfs.h> 39 40 #include <ipc/vol.h> 40 41 #include <stdbool.h> … … 75 76 /** Volume label */ 76 77 char label[VOL_LABEL_MAXLEN + 1]; 78 /** Current mount point */ 79 char cur_mp[MAX_PATH_LEN + 1]; /* XXX too big */ 80 /** Current mount point is automatic */ 81 bool cur_mp_auto; 77 82 } vol_part_info_t; 78 83 -
uspace/lib/c/include/vol.h
r5f36841 rdb9c889 37 37 38 38 #include <async.h> 39 #include <errno.h> 39 40 #include <loc.h> 40 41 #include <stdint.h> … … 47 48 extern errno_t vol_part_add(vol_t *, service_id_t); 48 49 extern errno_t vol_part_info(vol_t *, service_id_t, vol_part_info_t *); 50 extern errno_t vol_part_eject(vol_t *, service_id_t); 49 51 extern errno_t vol_part_empty(vol_t *, service_id_t); 50 52 extern errno_t vol_part_get_lsupp(vol_t *, vol_fstype_t, vol_label_supp_t *); 51 53 extern errno_t vol_part_mkfs(vol_t *, service_id_t, vol_fstype_t, const char *); 54 55 extern errno_t vol_fstype_format(vol_fstype_t, char **); 56 extern errno_t vol_pcnt_fs_format(vol_part_cnt_t, vol_fstype_t, char **); 52 57 53 58 #endif -
uspace/lib/fdisk/include/fdisk.h
r5f36841 rdb9c889 37 37 #define LIBFDISK_FDISK_H_ 38 38 39 #include <errno.h> 39 40 #include <loc.h> 40 41 #include <types/fdisk.h> … … 72 73 extern void fdisk_pspec_init(fdisk_part_spec_t *); 73 74 74 extern errno_t fdisk_ltype_format(label_type_t, char **);75 extern errno_t fdisk_fstype_format(vol_fstype_t, char **);76 extern errno_t fdisk_pkind_format(label_pkind_t, char **);77 78 75 extern errno_t fdisk_get_vollabel_support(fdisk_dev_t *, vol_fstype_t, 79 76 vol_label_supp_t *); -
uspace/lib/fdisk/src/fdisk.c
r5f36841 rdb9c889 813 813 } 814 814 815 errno_t fdisk_ltype_format(label_type_t ltype, char **rstr)816 {817 const char *sltype;818 char *s;819 820 sltype = NULL;821 switch (ltype) {822 case lt_none:823 sltype = "None";824 break;825 case lt_mbr:826 sltype = "MBR";827 break;828 case lt_gpt:829 sltype = "GPT";830 break;831 }832 833 s = str_dup(sltype);834 if (s == NULL)835 return ENOMEM;836 837 *rstr = s;838 return EOK;839 }840 841 errno_t fdisk_fstype_format(vol_fstype_t fstype, char **rstr)842 {843 const char *sfstype;844 char *s;845 846 sfstype = NULL;847 switch (fstype) {848 case fs_exfat:849 sfstype = "ExFAT";850 break;851 case fs_fat:852 sfstype = "FAT";853 break;854 case fs_minix:855 sfstype = "MINIX";856 break;857 case fs_ext4:858 sfstype = "Ext4";859 break;860 case fs_cdfs:861 sfstype = "ISO 9660";862 break;863 }864 865 s = str_dup(sfstype);866 if (s == NULL)867 return ENOMEM;868 869 *rstr = s;870 return EOK;871 }872 873 errno_t fdisk_pkind_format(label_pkind_t pkind, char **rstr)874 {875 const char *spkind;876 char *s;877 878 spkind = NULL;879 switch (pkind) {880 case lpk_primary:881 spkind = "Primary";882 break;883 case lpk_extended:884 spkind = "Extended";885 break;886 case lpk_logical:887 spkind = "Logical";888 break;889 }890 891 s = str_dup(spkind);892 if (s == NULL)893 return ENOMEM;894 895 *rstr = s;896 return EOK;897 }898 899 815 /** Get free partition index. */ 900 816 static errno_t fdisk_part_get_free_idx(fdisk_dev_t *dev, int *rindex)
Note:
See TracChangeset
for help on using the changeset viewer.