2
1

util-linux-susv3-legacy.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. [PATCH] replace susv3 legacy functions with modern equivalents
  2. Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
  3. ---
  4. fdisk/cfdisk.c | 2 +-
  5. fdisk/fdiskbsdlabel.c | 16 ++++++++--------
  6. fdisk/sfdisk.c | 10 +++++-----
  7. login-utils/login.c | 6 +++---
  8. login-utils/shutdown.c | 2 +-
  9. login-utils/ttymsg.c | 2 +-
  10. login-utils/vipw.c | 4 ++--
  11. login-utils/wall.c | 2 +-
  12. misc-utils/logger.c | 2 +-
  13. misc-utils/namei.c | 2 +-
  14. misc-utils/whereis.c | 4 ++--
  15. mount/mntent.c | 4 ++--
  16. mount/mount.c | 4 ++--
  17. mount/mount_by_label.c | 2 +-
  18. mount/sundries.c | 2 +-
  19. mount/umount.c | 2 +-
  20. partx/partx.c | 2 +-
  21. text-utils/colcrt.c | 4 ++--
  22. text-utils/display.c | 2 +-
  23. text-utils/parse.c | 8 ++++----
  24. 20 files changed, 41 insertions(+), 41 deletions(-)
  25. Index: util-linux-2.13-pre7/fdisk/fdiskbsdlabel.c
  26. ===================================================================
  27. --- util-linux-2.13-pre7.orig/fdisk/fdiskbsdlabel.c
  28. +++ util-linux-2.13-pre7/fdisk/fdiskbsdlabel.c
  29. @@ -538,10 +538,10 @@
  30. /* We need a backup of the disklabel (xbsd_dlabel might have changed). */
  31. d = &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE];
  32. - bcopy (d, &dl, sizeof (struct xbsd_disklabel));
  33. + memmove (&dl, d, sizeof (struct xbsd_disklabel));
  34. /* The disklabel will be overwritten by 0's from bootxx anyway */
  35. - bzero (d, sizeof (struct xbsd_disklabel));
  36. + memset (d, 0, sizeof (struct xbsd_disklabel));
  37. snprintf (path, sizeof(path), "%s/boot%s", bootdir, dkbasename);
  38. if (!xbsd_get_bootstrap (path, &disklabelbuffer[xbsd_dlabel.d_secsize],
  39. @@ -555,7 +555,7 @@
  40. exit ( EXIT_FAILURE );
  41. }
  42. - bcopy (&dl, d, sizeof (struct xbsd_disklabel));
  43. + memmove (d, &dl, sizeof (struct xbsd_disklabel));
  44. #if defined (__powerpc__) || defined (__hppa__)
  45. sector = 0;
  46. @@ -657,7 +657,7 @@
  47. struct geom g;
  48. get_geometry (fd, &g);
  49. - bzero (d, sizeof (struct xbsd_disklabel));
  50. + memset (d, 0, sizeof (struct xbsd_disklabel));
  51. d -> d_magic = BSD_DISKMAGIC;
  52. @@ -740,8 +740,8 @@
  53. if (BSD_BBSIZE != read (fd, disklabelbuffer, BSD_BBSIZE))
  54. fatal (unable_to_read);
  55. - bcopy (&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
  56. - d, sizeof (struct xbsd_disklabel));
  57. + memmove (d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
  58. + sizeof (struct xbsd_disklabel));
  59. if (d -> d_magic != BSD_DISKMAGIC || d -> d_magic2 != BSD_DISKMAGIC)
  60. return 0;
  61. @@ -776,8 +776,8 @@
  62. /* This is necessary if we want to write the bootstrap later,
  63. otherwise we'd write the old disklabel with the bootstrap.
  64. */
  65. - bcopy (d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
  66. - sizeof (struct xbsd_disklabel));
  67. + memmove (&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
  68. + d, sizeof (struct xbsd_disklabel));
  69. #if defined (__alpha__) && BSD_LABELSECTOR == 0
  70. alpha_bootblock_checksum (disklabelbuffer);
  71. Index: util-linux-2.13-pre7/login-utils/ttymsg.c
  72. ===================================================================
  73. --- util-linux-2.13-pre7.orig/login-utils/ttymsg.c
  74. +++ util-linux-2.13-pre7/login-utils/ttymsg.c
  75. @@ -111,7 +111,7 @@
  76. if (wret >= 0) {
  77. left -= wret;
  78. if (iov != localiov) {
  79. - bcopy(iov, localiov,
  80. + memmove(localiov, iov,
  81. iovcnt * sizeof(struct iovec));
  82. iov = localiov;
  83. }
  84. Index: util-linux-2.13-pre7/login-utils/vipw.c
  85. ===================================================================
  86. --- util-linux-2.13-pre7.orig/login-utils/vipw.c
  87. +++ util-linux-2.13-pre7/login-utils/vipw.c
  88. @@ -313,8 +313,8 @@
  89. bindtextdomain(PACKAGE, LOCALEDIR);
  90. textdomain(PACKAGE);
  91. - bzero(tmp_file, FILENAMELEN);
  92. - progname = (rindex(argv[0], '/')) ? rindex(argv[0], '/') + 1 : argv[0];
  93. + memset(tmp_file, 0, FILENAMELEN);
  94. + progname = (strrchr(argv[0], '/')) ? strrchr(argv[0], '/') + 1 : argv[0];
  95. if (!strcmp(progname, "vigr")) {
  96. program = VIGR;
  97. xstrncpy(orig_file, GROUP_FILE, sizeof(orig_file));
  98. Index: util-linux-2.13-pre7/misc-utils/logger.c
  99. ===================================================================
  100. --- util-linux-2.13-pre7.orig/misc-utils/logger.c
  101. +++ util-linux-2.13-pre7/misc-utils/logger.c
  102. @@ -198,7 +198,7 @@
  103. } else {
  104. if (p != buf)
  105. *p++ = ' ';
  106. - bcopy(*argv++, p, len);
  107. + memmove(p, *argv++, len);
  108. *(p += len) = '\0';
  109. }
  110. }
  111. Index: util-linux-2.13-pre7/misc-utils/namei.c
  112. ===================================================================
  113. --- util-linux-2.13-pre7.orig/misc-utils/namei.c
  114. +++ util-linux-2.13-pre7/misc-utils/namei.c
  115. @@ -242,7 +242,7 @@
  116. * call namei()
  117. */
  118. - bzero(sym, BUFSIZ);
  119. + memset(sym, 0, BUFSIZ);
  120. if(readlink(buf, sym, BUFSIZ) == -1){
  121. (void)printf(_(" ? problems reading symlink %s - %s (%d)\n"), buf, ERR);
  122. return;
  123. Index: util-linux-2.13-pre7/text-utils/colcrt.c
  124. ===================================================================
  125. --- util-linux-2.13-pre7.orig/text-utils/colcrt.c
  126. +++ util-linux-2.13-pre7/text-utils/colcrt.c
  127. @@ -252,8 +252,8 @@
  128. }
  129. putwchar('\n');
  130. }
  131. - bcopy(page[ol], page, (267 - ol) * 132 * sizeof(wchar_t));
  132. - bzero(page[267- ol], ol * 132 * sizeof(wchar_t));
  133. + memmove(page, page[ol], (267 - ol) * 132 * sizeof(wchar_t));
  134. + memset(page[267- ol], 0, ol * 132 * sizeof(wchar_t));
  135. outline -= ol;
  136. outcol = 0;
  137. first = 1;
  138. Index: util-linux-2.13-pre7/fdisk/sfdisk.c
  139. ===================================================================
  140. --- util-linux-2.13-pre7.orig/fdisk/sfdisk.c
  141. +++ util-linux-2.13-pre7/fdisk/sfdisk.c
  142. @@ -40,7 +40,7 @@
  143. #include <unistd.h> /* read, write */
  144. #include <fcntl.h> /* O_RDWR */
  145. #include <errno.h> /* ERANGE */
  146. -#include <string.h> /* index() */
  147. +#include <string.h> /* strchr() */
  148. #include <ctype.h>
  149. #include <getopt.h>
  150. #include <sys/ioctl.h>
  151. @@ -1709,12 +1709,12 @@
  152. eof = 1;
  153. return RD_EOF;
  154. }
  155. - if (!(lp = index(lp, '\n')))
  156. + if (!(lp = strchr(lp, '\n')))
  157. fatal(_("long or incomplete input line - quitting\n"));
  158. *lp = 0;
  159. /* remove comments, if any */
  160. - if ((lp = index(line+2, '#')) != 0)
  161. + if ((lp = strchr(line+2, '#')) != 0)
  162. *lp = 0;
  163. /* recognize a few commands - to be expanded */
  164. @@ -1724,7 +1724,7 @@
  165. }
  166. /* dump style? - then bad input is fatal */
  167. - if ((ip = index(line+2, ':')) != 0) {
  168. + if ((ip = strchr(line+2, ':')) != 0) {
  169. struct dumpfld *d;
  170. nxtfld:
  171. @@ -2491,7 +2491,7 @@
  172. if (argc < 1)
  173. fatal(_("no command?\n"));
  174. - if ((progn = rindex(argv[0], '/')) == NULL)
  175. + if ((progn = strrchr(argv[0], '/')) == NULL)
  176. progn = argv[0];
  177. else
  178. progn++;
  179. Index: util-linux-2.13-pre7/login-utils/login.c
  180. ===================================================================
  181. --- util-linux-2.13-pre7.orig/login-utils/login.c
  182. +++ util-linux-2.13-pre7/login-utils/login.c
  183. @@ -337,7 +337,7 @@
  184. */
  185. gethostname(tbuf, sizeof(tbuf));
  186. xstrncpy(thishost, tbuf, sizeof(thishost));
  187. - domain = index(tbuf, '.');
  188. + domain = strchr(tbuf, '.');
  189. username = tty_name = hostname = NULL;
  190. fflag = hflag = pflag = 0;
  191. @@ -356,7 +356,7 @@
  192. exit(1);
  193. }
  194. hflag = 1;
  195. - if (domain && (p = index(optarg, '.')) &&
  196. + if (domain && (p = strchr(optarg, '.')) &&
  197. strcasecmp(p, domain) == 0)
  198. *p = 0;
  199. @@ -1101,7 +1101,7 @@
  200. childArgv[childArgc++] = buff;
  201. } else {
  202. tbuf[0] = '-';
  203. - xstrncpy(tbuf + 1, ((p = rindex(pwd->pw_shell, '/')) ?
  204. + xstrncpy(tbuf + 1, ((p = strrchr(pwd->pw_shell, '/')) ?
  205. p + 1 : pwd->pw_shell),
  206. sizeof(tbuf)-1);
  207. Index: util-linux-2.13-pre7/login-utils/shutdown.c
  208. ===================================================================
  209. --- util-linux-2.13-pre7.orig/login-utils/shutdown.c
  210. +++ util-linux-2.13-pre7/login-utils/shutdown.c
  211. @@ -279,7 +279,7 @@
  212. if (fgets (line, sizeof(line), fp) != NULL &&
  213. strncasecmp (line, "HALT_ACTION", 11) == 0 &&
  214. iswhitespace(line[11])) {
  215. - p = index(line, '\n');
  216. + p = strchr(line, '\n');
  217. if (p)
  218. *p = 0; /* strip final '\n' */
  219. p = line+11;
  220. Index: util-linux-2.13-pre7/misc-utils/whereis.c
  221. ===================================================================
  222. --- util-linux-2.13-pre7.orig/misc-utils/whereis.c
  223. +++ util-linux-2.13-pre7/misc-utils/whereis.c
  224. @@ -323,14 +323,14 @@
  225. char dirbuf[1024];
  226. struct stat statbuf;
  227. - dd = index(dir, '*');
  228. + dd = strchr(dir, '*');
  229. if (!dd)
  230. goto noglob;
  231. l = strlen(dir);
  232. if (l < sizeof(dirbuf)) { /* refuse excessively long names */
  233. strcpy (dirbuf, dir);
  234. - d = index(dirbuf, '*');
  235. + d = strchr(dirbuf, '*');
  236. *d = 0;
  237. dirp = opendir(dirbuf);
  238. if (dirp == NULL)
  239. Index: util-linux-2.13-pre7/mount/mntent.c
  240. ===================================================================
  241. --- util-linux-2.13-pre7.orig/mount/mntent.c
  242. +++ util-linux-2.13-pre7/mount/mntent.c
  243. @@ -158,7 +158,7 @@
  244. return NULL;
  245. mfp->mntent_lineno++;
  246. - s = index (buf, '\n');
  247. + s = strchr (buf, '\n');
  248. if (s == NULL) {
  249. /* Missing final newline? Otherwise extremely */
  250. /* long line - assume file was corrupted */
  251. @@ -166,7 +166,7 @@
  252. fprintf(stderr, _("[mntent]: warning: no final "
  253. "newline at the end of %s\n"),
  254. mfp->mntent_file);
  255. - s = index (buf, 0);
  256. + s = strchr (buf, 0);
  257. } else {
  258. mfp->mntent_errs = 1;
  259. goto err;
  260. Index: util-linux-2.13-pre7/mount/mount.c
  261. ===================================================================
  262. --- util-linux-2.13-pre7.orig/mount/mount.c
  263. +++ util-linux-2.13-pre7/mount/mount.c
  264. @@ -488,11 +488,11 @@
  265. /* Accept a comma-separated list of types, and try them one by one */
  266. /* A list like "nonfs,.." indicates types not to use */
  267. - if (*types && strncmp(*types, "no", 2) && index(*types,',')) {
  268. + if (*types && strncmp(*types, "no", 2) && strchr(*types,',')) {
  269. char *t = strdup(*types);
  270. char *p;
  271. - while((p = index(t,',')) != NULL) {
  272. + while((p = strchr(t,',')) != NULL) {
  273. *p = 0;
  274. args.type = *types = t;
  275. if(do_mount_syscall (&args) == 0)
  276. Index: util-linux-2.13-pre7/mount/mount_by_label.c
  277. ===================================================================
  278. --- util-linux-2.13-pre7.orig/mount/mount_by_label.c
  279. +++ util-linux-2.13-pre7/mount/mount_by_label.c
  280. @@ -213,7 +213,7 @@
  281. fseek(procpt, 0, SEEK_SET);
  282. while (fgets(line, sizeof(line), procpt)) {
  283. - if (!index(line, '\n'))
  284. + if (!strchr(line, '\n'))
  285. break;
  286. if (sscanf (line, " %d %d %d %[^\n ]",
  287. Index: util-linux-2.13-pre7/mount/sundries.c
  288. ===================================================================
  289. --- util-linux-2.13-pre7.orig/mount/sundries.c
  290. +++ util-linux-2.13-pre7/mount/sundries.c
  291. @@ -138,7 +138,7 @@
  292. if (strncmp(p, type, len) == 0 &&
  293. (p[len] == 0 || p[len] == ','))
  294. return !no;
  295. - p = index(p,',');
  296. + p = strchr(p,',');
  297. if (!p)
  298. break;
  299. p++;
  300. Index: util-linux-2.13-pre7/mount/umount.c
  301. ===================================================================
  302. --- util-linux-2.13-pre7.orig/mount/umount.c
  303. +++ util-linux-2.13-pre7/mount/umount.c
  304. @@ -332,7 +332,7 @@
  305. if (res < 0)
  306. umnt_err2 = errno;
  307. /* Do not complain about remote NFS mount points */
  308. - if (errno == ENOENT && index(spec, ':'))
  309. + if (errno == ENOENT && strchr(spec, ':'))
  310. umnt_err2 = 0;
  311. }
  312. }
  313. Index: util-linux-2.13-pre7/partx/partx.c
  314. ===================================================================
  315. --- util-linux-2.13-pre7.orig/partx/partx.c
  316. +++ util-linux-2.13-pre7/partx/partx.c
  317. @@ -130,7 +130,7 @@
  318. case 'n':
  319. p = optarg;
  320. lower = atoi(p);
  321. - p = index(p, '-');
  322. + p = strchr(p, '-');
  323. if (p)
  324. upper = atoi(p+1);
  325. else
  326. Index: util-linux-2.13-pre7/text-utils/display.c
  327. ===================================================================
  328. --- util-linux-2.13-pre7.orig/text-utils/display.c
  329. +++ util-linux-2.13-pre7/text-utils/display.c
  330. @@ -163,7 +163,7 @@
  331. pr->cchar[0] = 's';
  332. pr->cchar[1] = 0;
  333. for (p1 = pr->fmt; *p1 != '%'; ++p1);
  334. - for (p2 = ++p1; *p1 && index(spec, *p1); ++p1);
  335. + for (p2 = ++p1; *p1 && strchr(spec, *p1); ++p1);
  336. while ((*p2++ = *p1++) != 0) ;
  337. }
  338. Index: util-linux-2.13-pre7/text-utils/parse.c
  339. ===================================================================
  340. --- util-linux-2.13-pre7.orig/text-utils/parse.c
  341. +++ util-linux-2.13-pre7/text-utils/parse.c
  342. @@ -64,7 +64,7 @@
  343. exit(1);
  344. }
  345. while (fgets(buf, sizeof(buf), fp)) {
  346. - if ((p = index(buf, '\n')) == NULL) {
  347. + if ((p = strchr(buf, '\n')) == NULL) {
  348. (void)fprintf(stderr, _("hexdump: line too long.\n"));
  349. while ((ch = getchar()) != '\n' && ch != EOF);
  350. continue;
  351. @@ -171,7 +171,7 @@
  352. * skip any special chars -- save precision in
  353. * case it's a %s format.
  354. */
  355. - while (index(spec + 1, *++fmt));
  356. + while (strchr(spec + 1, *++fmt));
  357. if (*fmt == '.' && isdigit((unsigned char)*++fmt)) {
  358. prec = atoi(fmt);
  359. while (isdigit((unsigned char)*++fmt));
  360. @@ -244,10 +244,10 @@
  361. if (fu->bcnt) {
  362. sokay = USEBCNT;
  363. /* skip to conversion character */
  364. - for (++p1; index(spec, *p1); ++p1);
  365. + for (++p1; strchr(spec, *p1); ++p1);
  366. } else {
  367. /* skip any special chars, field width */
  368. - while (index(spec + 1, *++p1));
  369. + while (strchr(spec + 1, *++p1));
  370. if (*p1 == '.' &&
  371. isdigit((unsigned char)*++p1)) {
  372. sokay = USEPREC;
  373. Index: util-linux-2.13-pre7/fdisk/cfdisk.c
  374. ===================================================================
  375. --- util-linux-2.13-pre7.orig/fdisk/cfdisk.c
  376. +++ util-linux-2.13-pre7/fdisk/cfdisk.c
  377. @@ -348,7 +348,7 @@
  378. /* Some libc's have their own basename() */
  379. static char *
  380. my_basename(char *devname) {
  381. - char *s = rindex(devname, '/');
  382. + char *s = strrchr(devname, '/');
  383. return s ? s+1 : devname;
  384. }
  385. Index: util-linux-2.13-pre7/login-utils/wall.c
  386. ===================================================================
  387. --- util-linux-2.13-pre7.orig/login-utils/wall.c
  388. +++ util-linux-2.13-pre7/login-utils/wall.c
  389. @@ -87,7 +87,7 @@
  390. textdomain(PACKAGE);
  391. progname = argv[0];
  392. - p = rindex(progname, '/');
  393. + p = strrchr(progname, '/');
  394. if (p)
  395. progname = p+1;