@@ -135,7 +135,6 @@ extern void libxfs_device_close (dev_t);
extern int libxfs_device_alignment (void);
extern void libxfs_report(FILE *);
extern void platform_findsizes(char *path, int fd, long long *sz, int *bsz);
-extern int platform_nproc(void);
/* check or write log footer: specify device, log size in blocks & uuid */
typedef char *(libxfs_get_block_t)(char *, int, void *);
@@ -77,4 +77,6 @@ typedef unsigned short umode_t;
# define ASSERT(EX) ((void) 0)
#endif
+extern int platform_nproc(void);
+
#endif /* __XFS_PLATFORM_DEFS_H__ */
@@ -242,10 +242,17 @@ platform_align_blockdev(void)
return max_block_alignment;
}
+/* How many CPUs are online? */
int
platform_nproc(void)
{
- return sysconf(_SC_NPROCESSORS_ONLN);
+ long nproc = sysconf(_SC_NPROCESSORS_ONLN);
+
+ if (nproc < 1)
+ return 1;
+ if (nproc >= INT_MAX)
+ return INT_MAX;
+ return nproc;
}
unsigned long