2 * util.c --- miscellaneous utilities
4 * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Public
20 #include <sys/utsname.h>
26 #define read_a_char() getch()
47 extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */
52 #include <sys/resource.h>
54 void fatal_error(e2fsck_t ctx, const char *msg)
56 ext2_filsys fs = ctx->fs;
57 int exit_value = FSCK_ERROR;
60 fprintf (stderr, "e2fsck: %s\n", msg);
63 if (fs->io && fs->super) {
64 ext2fs_mmp_stop(ctx->fs);
65 if (ctx->fs->io->magic == EXT2_ET_MAGIC_IO_CHANNEL)
66 io_channel_flush(ctx->fs->io);
68 log_err(ctx, "e2fsck: io manager magic bad!\n");
70 if (ext2fs_test_changed(fs)) {
71 exit_value |= FSCK_NONDESTRUCT;
72 log_out(ctx, _("\n%s: ***** FILE SYSTEM WAS MODIFIED *****\n"),
74 if (ctx->mount_flags & EXT2_MF_ISROOT)
75 exit_value |= FSCK_REBOOT;
77 if (!ext2fs_test_valid(fs)) {
78 log_out(ctx, _("\n%s: ********** WARNING: Filesystem still has "
79 "errors **********\n\n"), ctx->device_name);
80 exit_value |= FSCK_UNCORRECTED;
81 exit_value &= ~FSCK_NONDESTRUCT;
84 ctx->flags |= E2F_FLAG_ABORT;
85 if (ctx->flags & E2F_FLAG_SETJMP_OK)
86 longjmp(ctx->abort_loc, 1);
88 fprintf(ctx->logf, "Exit status: %d\n", exit_value);
93 static void thread_log_out(struct e2fsck_thread *tinfo)
95 printf("[Thread %d] %s", tinfo->et_thread_index,
97 tinfo->et_log_length = 0;
98 tinfo->et_log_buf[0] = '\0';
102 void log_out(e2fsck_t ctx, const char *fmt, ...)
105 struct e2fsck_thread *tinfo;
109 int fmt_length = strlen(fmt);
112 if ((ctx->options & E2F_OPT_MULTITHREAD) && ctx->global_ctx) {
113 tinfo = &ctx->thread_info;
114 buf_size = sizeof(tinfo->et_log_buf);
115 left_size = buf_size - tinfo->et_log_length;
118 msg_size = vsnprintf(tinfo->et_log_buf + tinfo->et_log_length,
119 left_size, fmt, pvar);
122 if (msg_size >= left_size) {
123 tinfo->et_log_buf[tinfo->et_log_length] = '\0';
125 assert(msg_size < buf_size);
126 if (msg_size < buf_size) {
127 thread_log_out(tinfo);
130 msg_size = vsnprintf(tinfo->et_log_buf, buf_size,
134 tinfo->et_log_length += msg_size;
135 tinfo->et_log_buf[tinfo->et_log_length] = '\0';
138 tinfo->et_log_length += msg_size;
139 tinfo->et_log_buf[tinfo->et_log_length] = '\0';
142 if (tinfo->et_log_length > 0 &&
143 tinfo->et_log_buf[tinfo->et_log_length - 1] == '\n')
144 thread_log_out(tinfo);
155 vfprintf(ctx->logf, fmt, pvar);
160 void log_err(e2fsck_t ctx, const char *fmt, ...)
165 vfprintf(stderr, fmt, pvar);
169 vfprintf(ctx->logf, fmt, pvar);
174 void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned long size,
175 const char *description)
180 #ifdef DEBUG_ALLOCATE_MEMORY
181 printf("Allocating %lu bytes for %s...\n", size, description);
183 if (ext2fs_get_memzero(size, &ret)) {
184 sprintf(buf, "Can't allocate %lu bytes for %s\n",
186 fatal_error(ctx, buf);
192 char *string_copy(e2fsck_t ctx EXT2FS_ATTR((unused)),
193 const char *str, size_t len)
203 strncpy(ret, str, len);
211 * Incredibly, libc5 doesn't appear to have strnlen. So we have to
214 int e2fsck_strnlen(const char * s, int count)
218 while (count-- && *cp)
225 static int read_a_char(void)
232 if (e2fsck_global_ctx &&
233 (e2fsck_global_ctx->flags & E2F_FLAG_CANCEL)) {
246 int ask_yn(e2fsck_t ctx, const char * string, int def)
250 const char *short_yes = _("yY");
251 const char *short_no = _("nN");
252 const char *short_yesall = _("aA");
253 const char *english_yes = "yY";
254 const char *english_no = "nN";
255 const char *english_yesall = "aA";
256 const char *yesall_prompt = _(" ('a' enables 'yes' to all) ");
257 const char *extra_prompt = "";
258 static int yes_answers;
260 #ifdef HAVE_TERMIOS_H
261 struct termios termios, tmp;
263 if (tcgetattr (0, &termios) < 0)
264 memset(&termios, 0, sizeof(termios));
266 tmp.c_lflag &= ~(ICANON | ECHO);
269 tcsetattr (0, TCSANOW, &tmp);
273 defstr = _(_("<y>"));
275 defstr = _(_("<n>"));
277 defstr = _(" (y/n)");
279 * If the user presses 'y' more than 8 (but less than 12) times in
280 * succession without pressing anything else, display a hint about
283 if (yes_answers > 12)
285 else if (yes_answers > 8)
286 extra_prompt = yesall_prompt;
287 log_out(ctx, "%s%s%s? ", string, extra_prompt, defstr);
290 if ((c = read_a_char()) == EOF)
293 #ifdef HAVE_TERMIOS_H
294 tcsetattr (0, TCSANOW, &termios);
296 if (ctx->flags & E2F_FLAG_SETJMP_OK) {
298 longjmp(e2fsck_global_ctx->abort_loc, 1);
300 log_out(ctx, "%s", _("cancelled!\n"));
304 if (strchr(short_yes, (char) c)) {
307 if (yes_answers >= 0)
310 } else if (strchr(short_no, (char) c)) {
315 } else if (strchr(short_yesall, (char)c)) {
319 ctx->options |= E2F_OPT_YES;
321 } else if (strchr(english_yes, (char) c)) {
323 } else if (strchr(english_no, (char) c)) {
325 } else if (strchr(english_yesall, (char) c)) {
327 } else if ((c == 27 || c == ' ' || c == '\n') && (def != -1)) {
333 log_out(ctx, "%s", _("yes to all\n"));
335 log_out(ctx, "%s", _("yes\n"));
337 log_out(ctx, "%s", _("no\n"));
338 #ifdef HAVE_TERMIOS_H
339 tcsetattr (0, TCSANOW, &termios);
344 int ask (e2fsck_t ctx, const char * string, int def)
346 if (ctx->options & E2F_OPT_NO) {
347 log_out(ctx, _("%s? no\n\n"), string);
350 if (ctx->options & E2F_OPT_YES) {
351 log_out(ctx, _("%s? yes\n\n"), string);
354 if (ctx->options & E2F_OPT_PREEN) {
355 log_out(ctx, "%s? %s\n\n", string, def ? _("yes") : _("no"));
358 return ask_yn(ctx, string, def);
361 void e2fsck_read_bitmaps(e2fsck_t ctx)
363 ext2_filsys fs = ctx->fs;
366 unsigned int save_type;
369 if (ctx->invalid_bitmaps) {
370 com_err(ctx->program_name, 0,
371 _("e2fsck_read_bitmaps: illegal bitmap block(s) for %s"),
376 old_op = ehandler_operation(_("reading inode and block bitmaps"));
377 e2fsck_set_bitmap_type(fs, EXT2FS_BMAP64_RBTREE, "fs_bitmaps",
379 flags = ctx->fs->flags;
380 ctx->fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
381 retval = ext2fs_read_bitmaps(fs);
382 ctx->fs->flags = (flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) |
383 (ctx->fs->flags & ~EXT2_FLAG_IGNORE_CSUM_ERRORS);
384 fs->default_bitmap_type = save_type;
385 ehandler_operation(old_op);
387 com_err(ctx->program_name, retval,
388 _("while retrying to read bitmaps for %s"),
394 void e2fsck_write_bitmaps(e2fsck_t ctx)
396 ext2_filsys fs = ctx->fs;
400 old_op = ehandler_operation(_("writing block and inode bitmaps"));
401 retval = ext2fs_write_bitmaps(fs);
402 ehandler_operation(old_op);
404 com_err(ctx->program_name, retval,
405 _("while rewriting block and inode bitmaps for %s"),
411 void preenhalt(e2fsck_t ctx)
413 ext2_filsys fs = ctx->fs;
415 if (!(ctx->options & E2F_OPT_PREEN))
417 log_err(ctx, _("\n\n%s: UNEXPECTED INCONSISTENCY; "
418 "RUN fsck MANUALLY.\n\t(i.e., without -a or -p options)\n"),
420 ctx->flags |= E2F_FLAG_EXITING;
422 fs->super->s_state |= EXT2_ERROR_FS;
423 ext2fs_mark_super_dirty(fs);
424 ext2fs_close_free(&fs);
426 exit(FSCK_UNCORRECTED);
429 #ifdef RESOURCE_TRACK
430 void init_resource_track(struct resource_track *track, io_channel channel)
432 #ifdef HAVE_GETRUSAGE
435 io_stats io_start = 0;
437 track->brk_start = sbrk(0);
438 gettimeofday(&track->time_start, 0);
439 #ifdef HAVE_GETRUSAGE
441 memset(&r, 0, sizeof(struct rusage));
443 getrusage(RUSAGE_SELF, &r);
444 track->user_start = r.ru_utime;
445 track->system_start = r.ru_stime;
447 track->user_start.tv_sec = track->user_start.tv_usec = 0;
448 track->system_start.tv_sec = track->system_start.tv_usec = 0;
450 track->bytes_read = 0;
451 track->bytes_written = 0;
452 if (channel && channel->manager && channel->manager->get_stats)
453 channel->manager->get_stats(channel, &io_start);
455 track->bytes_read = io_start->bytes_read;
456 track->bytes_written = io_start->bytes_written;
461 #define _INLINE_ __inline__
466 static _INLINE_ float timeval_subtract(struct timeval *tv1,
469 return ((tv1->tv_sec - tv2->tv_sec) +
470 ((float) (tv1->tv_usec - tv2->tv_usec)) / 1000000);
473 void print_resource_track(e2fsck_t ctx, const char *desc,
474 struct resource_track *track, io_channel channel)
476 #ifdef HAVE_GETRUSAGE
479 struct timeval time_end;
481 if ((desc && !(ctx->options & E2F_OPT_TIME2)) ||
482 (!desc && !(ctx->options & E2F_OPT_TIME)))
485 e2fsck_clear_progbar(ctx);
486 gettimeofday(&time_end, 0);
489 log_out(ctx, "%s: ", desc);
491 #define kbytes(x) (((unsigned long long)(x) + 1023) / 1024)
492 #ifdef HAVE_MALLINFO2
494 struct mallinfo2 malloc_info = mallinfo2();
496 log_out(ctx, _("Memory used: %lluk/%lluk (%lluk/%lluk), "),
497 kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd),
498 kbytes(malloc_info.uordblks),
499 kbytes(malloc_info.fordblks));
501 #elif defined HAVE_MALLINFO
502 /* don't use mallinfo() if over 2GB used, since it returns "int" */
503 if ((char *)sbrk(0) - (char *)track->brk_start < 2LL << 30) {
504 struct mallinfo malloc_info = mallinfo();
506 log_out(ctx, _("Memory used: %lluk/%lluk (%lluk/%lluk), "),
507 kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd),
508 kbytes(malloc_info.uordblks),
509 kbytes(malloc_info.fordblks));
512 log_out(ctx, _("Memory used: %lluk, "),
513 kbytes(((char *)sbrk(0)) - ((char *)track->brk_start)));
515 #ifdef HAVE_GETRUSAGE
516 getrusage(RUSAGE_SELF, &r);
518 log_out(ctx, _("time: %5.2f/%5.2f/%5.2f\n"),
519 timeval_subtract(&time_end, &track->time_start),
520 timeval_subtract(&r.ru_utime, &track->user_start),
521 timeval_subtract(&r.ru_stime, &track->system_start));
523 log_out(ctx, _("elapsed time: %6.3f\n"),
524 timeval_subtract(&time_end, &track->time_start));
526 #define mbytes(x) (((x) + 1048575) / 1048576)
527 if (channel && channel->manager && channel->manager->get_stats) {
529 unsigned long long bytes_read = 0;
530 unsigned long long bytes_written = 0;
533 log_out(ctx, "%s: ", desc);
535 channel->manager->get_stats(channel, &delta);
537 bytes_read = delta->bytes_read - track->bytes_read;
538 bytes_written = delta->bytes_written -
539 track->bytes_written;
541 log_out(ctx, "I/O read: %lluMB, write: %lluMB, "
543 mbytes(bytes_read), mbytes(bytes_written),
544 (double)mbytes(bytes_read + bytes_written) /
545 timeval_subtract(&time_end, &track->time_start));
548 #endif /* RESOURCE_TRACK */
550 void e2fsck_read_inode(e2fsck_t ctx, unsigned long ino,
551 struct ext2_inode * inode, const char *proc)
555 retval = ext2fs_read_inode(ctx->fs, ino, inode);
557 com_err("ext2fs_read_inode", retval,
558 _("while reading inode %lu in %s"), ino, proc);
563 void e2fsck_read_inode_full(e2fsck_t ctx, unsigned long ino,
564 struct ext2_inode *inode, int bufsize,
569 retval = ext2fs_read_inode_full(ctx->fs, ino, inode, bufsize);
571 com_err("ext2fs_read_inode_full", retval,
572 _("while reading inode %lu in %s"), ino, proc);
578 #define e2fsck_get_lock_context(ctx) \
579 e2fsck_t global_ctx = ctx->global_ctx; \
583 void e2fsck_pass1_fix_lock(e2fsck_t ctx)
585 e2fsck_get_lock_context(ctx);
586 pthread_mutex_lock(&global_ctx->fs_fix_mutex);
589 void e2fsck_pass1_fix_unlock(e2fsck_t ctx)
591 e2fsck_get_lock_context(ctx);
592 pthread_mutex_unlock(&global_ctx->fs_fix_mutex);
595 void e2fsck_pass1_block_map_w_lock(e2fsck_t ctx)
597 e2fsck_get_lock_context(ctx);
598 pthread_rwlock_wrlock(&global_ctx->fs_block_map_rwlock);
601 void e2fsck_pass1_block_map_w_unlock(e2fsck_t ctx)
603 e2fsck_get_lock_context(ctx);
604 pthread_rwlock_unlock(&global_ctx->fs_block_map_rwlock);
607 void e2fsck_pass1_block_map_r_lock(e2fsck_t ctx)
609 e2fsck_get_lock_context(ctx);
610 pthread_rwlock_rdlock(&global_ctx->fs_block_map_rwlock);
613 void e2fsck_pass1_block_map_r_unlock(e2fsck_t ctx)
615 e2fsck_get_lock_context(ctx);
616 pthread_rwlock_unlock(&global_ctx->fs_block_map_rwlock);
619 void e2fsck_pass1_fix_lock(e2fsck_t ctx)
624 void e2fsck_pass1_fix_unlock(e2fsck_t ctx)
628 void e2fsck_pass1_block_map_w_lock(e2fsck_t ctx)
633 void e2fsck_pass1_block_map_w_unlock(e2fsck_t ctx)
638 void e2fsck_pass1_block_map_r_lock(e2fsck_t ctx)
643 void e2fsck_pass1_block_map_r_unlock(e2fsck_t ctx)
649 void e2fsck_write_inode_full(e2fsck_t ctx, unsigned long ino,
650 struct ext2_inode * inode, int bufsize,
655 e2fsck_pass1_fix_lock(ctx);
656 retval = ext2fs_write_inode_full(ctx->fs, ino, inode, bufsize);
657 e2fsck_pass1_fix_unlock(ctx);
659 com_err("ext2fs_write_inode", retval,
660 _("while writing inode %lu in %s"), ino, proc);
665 void e2fsck_write_inode(e2fsck_t ctx, unsigned long ino,
666 struct ext2_inode * inode, const char *proc)
670 e2fsck_pass1_fix_lock(ctx);
671 retval = ext2fs_write_inode(ctx->fs, ino, inode);
672 e2fsck_pass1_fix_unlock(ctx);
674 com_err("ext2fs_write_inode", retval,
675 _("while writing inode %lu in %s"), ino, proc);
681 void mtrace_print(char *mesg)
683 FILE *malloc_get_mallstream();
684 FILE *f = malloc_get_mallstream();
687 fprintf(f, "============= %s\n", mesg);
691 blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,
694 struct ext2_super_block *sb;
695 io_channel io = NULL;
698 blk64_t superblock, ret_sb = 8193;
700 if (fs && fs->super) {
701 ret_sb = (fs->super->s_blocks_per_group +
702 fs->super->s_first_data_block);
704 ctx->superblock = ret_sb;
705 ctx->blocksize = fs->blocksize;
711 if (ctx->blocksize) {
712 ret_sb = ctx->blocksize * 8;
713 if (ctx->blocksize == 1024)
715 ctx->superblock = ret_sb;
718 ctx->superblock = ret_sb;
719 ctx->blocksize = 1024;
722 if (!name || !manager)
725 if (manager->open(name, 0, &io) != 0)
728 if (ext2fs_get_mem(SUPERBLOCK_SIZE, &buf))
730 sb = (struct ext2_super_block *) buf;
732 for (blocksize = EXT2_MIN_BLOCK_SIZE;
733 blocksize <= EXT2_MAX_BLOCK_SIZE ; blocksize *= 2) {
734 superblock = blocksize*8;
735 if (blocksize == 1024)
737 io_channel_set_blksize(io, blocksize);
738 if (io_channel_read_blk64(io, superblock,
739 -SUPERBLOCK_SIZE, buf))
741 #ifdef WORDS_BIGENDIAN
742 if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
743 ext2fs_swap_super(sb);
745 if ((sb->s_magic == EXT2_SUPER_MAGIC) &&
746 (EXT2_BLOCK_SIZE(sb) == blocksize)) {
749 ctx->superblock = superblock;
750 ctx->blocksize = blocksize;
758 io_channel_close(io);
760 ext2fs_free_mem(&buf);
765 * Given a mode, return the ext2 file type
767 int ext2_file_type(unsigned int mode)
769 if (LINUX_S_ISREG(mode))
770 return EXT2_FT_REG_FILE;
772 if (LINUX_S_ISDIR(mode))
775 if (LINUX_S_ISCHR(mode))
776 return EXT2_FT_CHRDEV;
778 if (LINUX_S_ISBLK(mode))
779 return EXT2_FT_BLKDEV;
781 if (LINUX_S_ISLNK(mode))
782 return EXT2_FT_SYMLINK;
784 if (LINUX_S_ISFIFO(mode))
787 if (LINUX_S_ISSOCK(mode))
794 * Check to see if a filesystem is in /proc/filesystems.
795 * Returns 1 if found, 0 if not
797 int fs_proc_check(const char *fs_name)
800 char buf[80], *cp, *t;
802 f = fopen("/proc/filesystems", "r");
806 if (!fgets(buf, sizeof(buf), f))
810 while (*cp && !isspace(*cp))
813 while (*cp && isspace(*cp))
815 if ((t = strchr(cp, '\n')) != NULL)
817 if ((t = strchr(cp, '\t')) != NULL)
819 if ((t = strchr(cp, ' ')) != NULL)
821 if (!strcmp(fs_name, cp)) {
831 * Check to see if a filesystem is available as a module
832 * Returns 1 if found, 0 if not
834 int check_for_modules(const char *fs_name)
839 char buf[1024], *cp, *t;
844 snprintf(buf, sizeof(buf), "/lib/modules/%s/modules.dep", uts.release);
850 if (!fgets(buf, sizeof(buf), f))
852 if ((cp = strchr(buf, ':')) != NULL)
856 if ((cp = strrchr(buf, '/')) != NULL)
863 if (!strcmp(t, ".ko"))
866 if (!strcmp(cp, fs_name)) {
872 #endif /* __linux__ */
877 * Helper function that does the right thing if write returns a
878 * partial write, or an EAGAIN/EINTR error.
880 int write_all(int fd, char *buf, size_t count)
886 ret = write(fd, buf, count);
888 if ((errno == EAGAIN) || (errno == EINTR))
899 void dump_mmp_msg(struct mmp_struct *mmp, const char *fmt, ...)
904 printf("MMP check failed: ");
910 time_t t = mmp->mmp_time;
912 printf("MMP_block:\n");
913 printf(" mmp_magic: 0x%x\n", mmp->mmp_magic);
914 printf(" mmp_check_interval: %d\n",
915 mmp->mmp_check_interval);
916 printf(" mmp_sequence: %08x\n", mmp->mmp_seq);
917 printf(" mmp_update_date: %s", ctime(&t));
918 printf(" mmp_update_time: %lld\n",
919 (long long) mmp->mmp_time);
920 printf(" mmp_node_name: %.*s\n",
921 EXT2_LEN_STR(mmp->mmp_nodename));
922 printf(" mmp_device_name: %.*s\n",
923 EXT2_LEN_STR(mmp->mmp_bdevname));
927 errcode_t e2fsck_mmp_update(ext2_filsys fs)
931 retval = ext2fs_mmp_update(fs);
932 if (retval == EXT2_ET_MMP_CHANGE_ABORT)
933 dump_mmp_msg(fs->mmp_cmp,
934 _("UNEXPECTED INCONSISTENCY: the filesystem is "
935 "being modified while fsck is running.\n"));
940 void e2fsck_set_bitmap_type(ext2_filsys fs, unsigned int default_type,
941 const char *profile_name, unsigned int *old_type)
944 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
947 *old_type = fs->default_bitmap_type;
948 profile_get_uint(ctx->profile, "bitmaps", profile_name, 0,
949 default_type, &type);
950 profile_get_uint(ctx->profile, "bitmaps", "all", 0, type, &type);
951 fs->default_bitmap_type = type ? type : default_type;
954 errcode_t e2fsck_allocate_inode_bitmap(ext2_filsys fs, const char *descr,
957 ext2fs_inode_bitmap *ret)
960 unsigned int save_type;
962 e2fsck_set_bitmap_type(fs, deftype, name, &save_type);
963 retval = ext2fs_allocate_inode_bitmap(fs, descr, ret);
964 fs->default_bitmap_type = save_type;
968 errcode_t e2fsck_allocate_block_bitmap(ext2_filsys fs, const char *descr,
971 ext2fs_block_bitmap *ret)
974 unsigned int save_type;
976 e2fsck_set_bitmap_type(fs, deftype, name, &save_type);
977 retval = ext2fs_allocate_block_bitmap(fs, descr, ret);
978 fs->default_bitmap_type = save_type;
982 errcode_t e2fsck_allocate_subcluster_bitmap(ext2_filsys fs, const char *descr,
985 ext2fs_block_bitmap *ret)
988 unsigned int save_type;
990 e2fsck_set_bitmap_type(fs, deftype, name, &save_type);
991 retval = ext2fs_allocate_subcluster_bitmap(fs, descr, ret);
992 fs->default_bitmap_type = save_type;
996 /* Return memory size in bytes */
997 unsigned long long get_memory_size(void)
999 #if defined(_SC_PHYS_PAGES)
1000 # if defined(_SC_PAGESIZE)
1001 return (unsigned long long)sysconf(_SC_PHYS_PAGES) *
1002 (unsigned long long)sysconf(_SC_PAGESIZE);
1003 # elif defined(_SC_PAGE_SIZE)
1004 return (unsigned long long)sysconf(_SC_PHYS_PAGES) *
1005 (unsigned long long)sysconf(_SC_PAGE_SIZE);
1007 #elif defined(CTL_HW)
1008 # if (defined(HW_MEMSIZE) || defined(HW_PHYSMEM64))
1009 # define CTL_HW_INT64
1010 # elif (defined(HW_PHYSMEM) || defined(HW_REALMEM))
1011 # define CTL_HW_UINT
1016 # if defined(HW_MEMSIZE)
1017 mib[1] = HW_MEMSIZE;
1018 # elif defined(HW_PHYSMEM64)
1019 mib[1] = HW_PHYSMEM64;
1020 # elif defined(HW_REALMEM)
1021 mib[1] = HW_REALMEM;
1022 # elif defined(HW_PYSMEM)
1023 mib[1] = HW_PHYSMEM;
1025 # if defined(CTL_HW_INT64)
1026 unsigned long long size = 0;
1027 # elif defined(CTL_HW_UINT)
1028 unsigned int size = 0;
1032 # warning "Don't know how to detect memory on your platform?"