Changeset da680b4b in mainline
- Timestamp:
- 2018-07-06T17:18:28Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6419c6e
- Parents:
- 9ba040a
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/str.c
r9ba040a rda680b4b 1134 1134 return (char *) (str + last); 1135 1135 last = off; 1136 } 1137 1138 return NULL; 1139 } 1140 1141 /** Find first occurence of substring in string. 1142 * 1143 * @param hs Haystack (string) 1144 * @param n Needle (substring to look for) 1145 * 1146 * @return Pointer to character in @a hs or @c NULL if not found. 1147 */ 1148 char *str_str(const char *hs, const char *n) 1149 { 1150 size_t off = 0; 1151 1152 if (str_lcmp(hs, n, str_length(n)) == 0) 1153 return (char *)hs; 1154 1155 while (str_decode(hs, &off, STR_NO_LIMIT) != 0) { 1156 if (str_lcmp(hs + off, n, str_length(n)) == 0) 1157 return (char *)(hs + off); 1136 1158 } 1137 1159 -
uspace/lib/c/include/str.h
r9ba040a rda680b4b 108 108 extern char *str_chr(const char *str, wchar_t ch); 109 109 extern char *str_rchr(const char *str, wchar_t ch); 110 extern char *str_str(const char *hs, const char *n); 110 111 111 112 extern void str_rtrim(char *str, wchar_t ch); -
uspace/lib/c/test/str.c
r9ba040a rda680b4b 88 88 } 89 89 90 PCUT_TEST(str_str_found) 91 { 92 const char *hs = "abracadabra"; 93 const char *n = "raca"; 94 char *p; 95 96 p = str_str(hs, n); 97 PCUT_ASSERT_TRUE((const char *)p == hs + 2); 98 } 99 100 PCUT_TEST(str_str_not_found) 101 { 102 const char *hs = "abracadabra"; 103 const char *n = "racab"; 104 char *p; 105 106 p = str_str(hs, n); 107 PCUT_ASSERT_TRUE(p == NULL); 108 } 109 110 PCUT_TEST(str_str_empty_n) 111 { 112 const char *hs = "abracadabra"; 113 const char *n = ""; 114 char *p; 115 116 p = str_str(hs, n); 117 PCUT_ASSERT_TRUE((const char *)p == hs); 118 } 90 119 91 120 PCUT_EXPORT(str); -
uspace/srv/volsrv/part.c
r9ba040a rda680b4b 256 256 } 257 257 258 /** Determine if partition is allowed to be mounted by default. 259 * 260 * @param part Partition 261 * @return @c true iff partition is allowed to be mounted by default 262 */ 263 static bool vol_part_allow_mount_by_def(vol_part_t *part) 264 { 265 /* CDFS is safe to mount (after all, it is read-only) */ 266 if (part->pcnt == vpc_fs && part->fstype == fs_cdfs) 267 return true; 268 269 /* For other file systems disallow mounting from ATA hard drive */ 270 if (str_str(part->svc_name, "\\ata-c") != NULL) 271 return false; 272 273 /* Allow otherwise (e.g. USB mass storage) */ 274 return true; 275 } 276 258 277 static errno_t vol_part_mount(vol_part_t *part) 259 278 { … … 265 284 /* Don't mount nameless volumes */ 266 285 log_msg(LOG_DEFAULT, LVL_NOTE, "Not mounting nameless partition."); 286 return EOK; 287 } 288 289 if (!vol_part_allow_mount_by_def(part)) { 290 /* Don't mount partition by default */ 291 log_msg(LOG_DEFAULT, LVL_NOTE, "Not mounting per default policy."); 267 292 return EOK; 268 293 }
Note:
See TracChangeset
for help on using the changeset viewer.