- if (ff_pkt->statp.st_nlink > 1
- && (S_ISREG(ff_pkt->statp.st_mode)
- || S_ISCTG(ff_pkt->statp.st_mode)
- || S_ISCHR(ff_pkt->statp.st_mode)
- || S_ISBLK(ff_pkt->statp.st_mode)
- || S_ISFIFO(ff_pkt->statp.st_mode)
- || S_ISSOCK(ff_pkt->statp.st_mode))) {
+/*
+ * Find a single file.
+ * handle_file is the callback for handling the file.
+ * p is the filename
+ * parent_device is the device we are currently on
+ * top_level is 1 when not recursing or 0 when
+ * descending into a directory.
+ */
+int
+find_one_file(JCR *jcr, FF_PKT *ff_pkt,
+ int handle_file(JCR *jcr, FF_PKT *ff, bool top_level),
+ char *fname, dev_t parent_device, bool top_level)
+{
+ struct utimbuf restore_times;
+ int rtn_stat;
+ int len;
+
+ ff_pkt->fname = ff_pkt->link = fname;
+
+ if (lstat(fname, &ff_pkt->statp) != 0) {
+ /* Cannot stat file */
+ ff_pkt->type = FT_NOSTAT;
+ ff_pkt->ff_errno = errno;
+ return handle_file(jcr, ff_pkt, top_level);
+ }
+
+ Dmsg1(300, "File ----: %s\n", fname);
+
+ /* Save current times of this directory in case we need to
+ * reset them because the user doesn't want them changed.
+ */
+ restore_times.actime = ff_pkt->statp.st_atime;
+ restore_times.modtime = ff_pkt->statp.st_mtime;
+
+ /*
+ * We check for allowed fstypes and drivetypes at top_level and fstype change (below).
+ */
+ if (top_level) {
+ if (!accept_fstype(ff_pkt, NULL)) {
+ ff_pkt->type = FT_INVALIDFS;
+ if (ff_pkt->flags & FO_KEEPATIME) {
+ utime(fname, &restore_times);
+ }
+
+ char fs[100];
+
+ if (!fstype(ff_pkt->fname, fs, sizeof(fs))) {
+ bstrncpy(fs, "unknown", sizeof(fs));
+ }
+
+ Jmsg(jcr, M_INFO, 0, _("Top level directory \"%s\" has unlisted fstype \"%s\"\n"), fname, fs);
+ return 1; /* Just ignore this error - or the whole backup is cancelled */
+ }
+ if (!accept_drivetype(ff_pkt, NULL)) {
+ ff_pkt->type = FT_INVALIDDT;
+ if (ff_pkt->flags & FO_KEEPATIME) {
+ utime(fname, &restore_times);
+ }