@@ -160,6 +160,18 @@ class StressInterImpl: public StressGenInter {
160160 return true ;
161161 }
162162
163+ bool build_gen_mtime (StressNode *node, struct in_mem_meta *meta) override {
164+ size_t now = time (nullptr );
165+ time_t time_sec = get_randomint (now, now + 24 * 60 * 60 );
166+ struct tm *time_info = localtime (&time_sec);
167+ char buffer[256 ];
168+ strftime (buffer, sizeof (buffer), " %Y-%m-%d %H:%M:%S" , time_info);
169+ std::ostringstream oss;
170+ oss << buffer;
171+ meta->mtime_date = oss.str ();
172+ meta->mtime = time_sec;
173+ return true ;
174+ }
163175 /* generate a random dir or file name in the current layer */
164176 std::string generate_name (int idx, int depth, std::string root_path, NODE_TYPE type) override {
165177 std::string res;
@@ -198,6 +210,10 @@ class StressInterImpl: public StressGenInter {
198210 return true ;
199211 }
200212
213+ bool build_dir_mtime (StressNode *node, struct in_mem_meta *meta) override {
214+ return build_gen_mtime (node, meta);
215+ }
216+
201217 bool build_dir_xattrs (StressNode *node, const char *path, photon::fs::IFileSystem *host_fs) override {
202218 photon::fs::IFileSystemXAttr *xattr_ops = dynamic_cast <photon::fs::IFileSystemXAttr*>(host_fs);
203219 if (xattr_ops == nullptr )
@@ -219,6 +235,7 @@ class StressInterImpl: public StressGenInter {
219235 LOG_ERRNO_RETURN (-1 , false , " fail to stat file `" , file_info->path );
220236 node->node_stat .st_uid = meta->uid ;
221237 node->node_stat .st_gid = meta->gid ;
238+ node->node_stat .st_mtime = meta->mtime ;
222239
223240 return true ;
224241 }
@@ -228,6 +245,7 @@ class StressInterImpl: public StressGenInter {
228245 LOG_ERROR_RETURN (-1 , false , " fail to stat dir `" , path);
229246 node->node_stat .st_uid = meta->uid ;
230247 node->node_stat .st_gid = meta->gid ;
248+ node->node_stat .st_mtime = meta->mtime ;
231249 return true ;
232250 }
233251
@@ -257,6 +275,9 @@ class StressCase001: public StressBase, public StressInterImpl {
257275 bool build_gen_own (StressNode *node, struct in_mem_meta *meta) override {
258276 return StressInterImpl::build_gen_own (node, meta);
259277 }
278+ bool build_gen_mtime (StressNode *node, struct in_mem_meta *meta) override {
279+ return StressInterImpl::build_gen_mtime (node, meta);
280+ }
260281 bool build_stat_file (StressNode *node, StressHostFile *file, struct in_mem_meta *meta) override {
261282 return StressInterImpl::build_stat_file (node, file, meta);
262283 }
@@ -267,6 +288,9 @@ class StressCase001: public StressBase, public StressInterImpl {
267288 bool build_dir_own (StressNode *node, struct in_mem_meta *meta) override {
268289 return StressInterImpl::build_dir_own (node, meta);
269290 }
291+ bool build_dir_mtime (StressNode *node, struct in_mem_meta *meta) override {
292+ return StressInterImpl::build_dir_mtime (node, meta);
293+ }
270294 bool build_dir_xattrs (StressNode *node, const char *path, photon::fs::IFileSystem *host_fs) override {
271295 return StressInterImpl::build_dir_xattrs (node, path, host_fs);
272296 }
@@ -296,8 +320,8 @@ class StressCase001: public StressBase, public StressInterImpl {
296320 std::vector<int > layer_dirs (int idx) {
297321 std::vector<int > ret;
298322
299- ret.emplace_back (50 );
300- ret.emplace_back (50 );
323+ ret.emplace_back (3 );
324+ ret.emplace_back (3 );
301325 return ret;
302326 }
303327};
@@ -320,6 +344,9 @@ class StressCase002: public StressBase, public StressInterImpl {
320344 bool build_gen_own (StressNode *node, struct in_mem_meta *meta) override {
321345 return StressInterImpl::build_gen_own (node, meta);
322346 }
347+ bool build_gen_mtime (StressNode *node, struct in_mem_meta *meta) override {
348+ return StressInterImpl::build_gen_mtime (node, meta);
349+ }
323350 bool build_gen_content (StressNode *node, StressHostFile *file) override {
324351 return StressInterImpl::build_gen_content (node, file);
325352 }
@@ -333,6 +360,9 @@ class StressCase002: public StressBase, public StressInterImpl {
333360 bool build_dir_own (StressNode *node, struct in_mem_meta *meta) override {
334361 return StressInterImpl::build_dir_own (node, meta);
335362 }
363+ bool build_dir_mtime (StressNode *node, struct in_mem_meta *meta) override {
364+ return StressInterImpl::build_dir_mtime (node, meta);
365+ }
336366 bool build_dir_xattrs (StressNode *node, const char *path, photon::fs::IFileSystem *host_fs) override {
337367 return StressInterImpl::build_dir_xattrs (node, path, host_fs);
338368 }
@@ -388,6 +418,9 @@ class StressCase003: public StressBase, public StressInterImpl {
388418 bool build_gen_own (StressNode *node, struct in_mem_meta *meta) override {
389419 return StressInterImpl::build_gen_own (node, meta);
390420 }
421+ bool build_gen_mtime (StressNode *node, struct in_mem_meta *meta) override {
422+ return StressInterImpl::build_gen_mtime (node, meta);
423+ }
391424 bool build_gen_xattrs (StressNode *node, StressHostFile *file) override {
392425 return StressInterImpl::build_gen_xattrs (node, file);
393426 }
@@ -401,6 +434,9 @@ class StressCase003: public StressBase, public StressInterImpl {
401434 bool build_dir_own (StressNode *node, struct in_mem_meta *meta) override {
402435 return StressInterImpl::build_dir_own (node, meta);
403436 }
437+ bool build_dir_mtime (StressNode *node, struct in_mem_meta *meta) override {
438+ return StressInterImpl::build_dir_mtime (node, meta);
439+ }
404440 bool build_dir_xattrs (StressNode *node, const char *path, photon::fs::IFileSystem *host_fs) override {
405441 return StressInterImpl::build_dir_xattrs (node, path, host_fs);
406442 }
@@ -449,6 +485,9 @@ class StressCase004: public StressBase, public StressInterImpl {
449485 bool build_gen_own (StressNode *node, struct in_mem_meta *meta) override {
450486 return StressInterImpl::build_gen_own (node, meta);
451487 }
488+ bool build_gen_mtime (StressNode *node, struct in_mem_meta *meta) override {
489+ return StressInterImpl::build_gen_mtime (node, meta);
490+ }
452491 bool build_gen_mod (StressNode *node, StressHostFile *file) override {
453492 return StressInterImpl::build_gen_mod (node, file);
454493 }
@@ -462,6 +501,9 @@ class StressCase004: public StressBase, public StressInterImpl {
462501 bool build_dir_own (StressNode *node, struct in_mem_meta *meta) override {
463502 return StressInterImpl::build_dir_own (node, meta);
464503 }
504+ bool build_dir_mtime (StressNode *node, struct in_mem_meta *meta) override {
505+ return StressInterImpl::build_dir_mtime (node, meta);
506+ }
465507 bool build_dir_xattrs (StressNode *node, const char *path, photon::fs::IFileSystem *host_fs) override {
466508 return StressInterImpl::build_dir_xattrs (node, path, host_fs);
467509 }
@@ -510,6 +552,9 @@ class StressCase005: public StressBase, public StressInterImpl {
510552 bool build_gen_own (StressNode *node, struct in_mem_meta *meta) override {
511553 return StressInterImpl::build_gen_own (node, meta);
512554 }
555+ bool build_gen_mtime (StressNode *node, struct in_mem_meta *meta) override {
556+ return StressInterImpl::build_gen_mtime (node, meta);
557+ }
513558 bool build_stat_file (StressNode *node, StressHostFile *file, struct in_mem_meta *meta) override {
514559 return StressInterImpl::build_stat_file (node, file, meta);
515560 }
@@ -520,6 +565,9 @@ class StressCase005: public StressBase, public StressInterImpl {
520565 bool build_dir_own (StressNode *node, struct in_mem_meta *meta) override {
521566 return StressInterImpl::build_dir_own (node, meta);
522567 }
568+ bool build_dir_mtime (StressNode *node, struct in_mem_meta *meta) override {
569+ return StressInterImpl::build_dir_mtime (node, meta);
570+ }
523571 bool build_dir_xattrs (StressNode *node, const char *path, photon::fs::IFileSystem *host_fs) override {
524572 return StressInterImpl::build_dir_xattrs (node, path, host_fs);
525573 }
@@ -568,6 +616,9 @@ class StressCase006: public StressBase, public StressInterImpl {
568616 bool build_gen_own (StressNode *node, struct in_mem_meta *meta) override {
569617 return StressInterImpl::build_gen_own (node, meta);
570618 }
619+ bool build_gen_mtime (StressNode *node, struct in_mem_meta *meta) override {
620+ return StressInterImpl::build_gen_mtime (node, meta);
621+ }
571622 bool build_gen_xattrs (StressNode *node, StressHostFile *file) override {
572623 return StressInterImpl::build_gen_xattrs (node, file);
573624 }
@@ -584,6 +635,9 @@ class StressCase006: public StressBase, public StressInterImpl {
584635 bool build_dir_own (StressNode *node, struct in_mem_meta *meta) override {
585636 return StressInterImpl::build_dir_own (node, meta);
586637 }
638+ bool build_dir_mtime (StressNode *node, struct in_mem_meta *meta) override {
639+ return StressInterImpl::build_dir_mtime (node, meta);
640+ }
587641 bool build_dir_xattrs (StressNode *node, const char *path, photon::fs::IFileSystem *host_fs) override {
588642 return StressInterImpl::build_dir_xattrs (node, path, host_fs);
589643 }
@@ -636,6 +690,9 @@ class StressCase007: public StressBase, public StressInterImpl {
636690 bool build_gen_own (StressNode *node, struct in_mem_meta *meta) override {
637691 return StressInterImpl::build_gen_own (node, meta);
638692 }
693+ bool build_gen_mtime (StressNode *node, struct in_mem_meta *meta) override {
694+ return StressInterImpl::build_gen_mtime (node, meta);
695+ }
639696 bool build_gen_xattrs (StressNode *node, StressHostFile *file) override {
640697 return StressInterImpl::build_gen_xattrs (node, file);
641698 }
@@ -652,6 +709,9 @@ class StressCase007: public StressBase, public StressInterImpl {
652709 bool build_dir_own (StressNode *node, struct in_mem_meta *meta) override {
653710 return StressInterImpl::build_dir_own (node, meta);
654711 }
712+ bool build_dir_mtime (StressNode *node, struct in_mem_meta *meta) override {
713+ return StressInterImpl::build_dir_mtime (node, meta);
714+ }
655715 bool build_dir_xattrs (StressNode *node, const char *path, photon::fs::IFileSystem *host_fs) override {
656716 return StressInterImpl::build_dir_xattrs (node, path, host_fs);
657717 }
@@ -724,6 +784,9 @@ class StressCase008: public StressBase, public StressInterImpl {
724784 bool build_gen_own (StressNode *node, struct in_mem_meta *meta) override {
725785 return StressInterImpl::build_gen_own (node, meta);
726786 }
787+ bool build_gen_mtime (StressNode *node, struct in_mem_meta *meta) override {
788+ return StressInterImpl::build_gen_mtime (node, meta);
789+ }
727790 bool build_gen_xattrs (StressNode *node, StressHostFile *file) override {
728791 return StressInterImpl::build_gen_xattrs (node, file);
729792 }
@@ -740,6 +803,9 @@ class StressCase008: public StressBase, public StressInterImpl {
740803 bool build_dir_own (StressNode *node, struct in_mem_meta *meta) override {
741804 return StressInterImpl::build_dir_own (node, meta);
742805 }
806+ bool build_dir_mtime (StressNode *node, struct in_mem_meta *meta) override {
807+ return StressInterImpl::build_dir_mtime (node, meta);
808+ }
743809 bool build_dir_xattrs (StressNode *node, const char *path, photon::fs::IFileSystem *host_fs) override {
744810 return StressInterImpl::build_dir_xattrs (node, path, host_fs);
745811 }
@@ -821,6 +887,9 @@ class StressCase009: public StressBase, public StressInterImpl {
821887 bool build_gen_own (StressNode *node, struct in_mem_meta *meta) override {
822888 return StressInterImpl::build_gen_own (node, meta);
823889 }
890+ bool build_gen_mtime (StressNode *node, struct in_mem_meta *meta) override {
891+ return StressInterImpl::build_gen_mtime (node, meta);
892+ }
824893 bool build_gen_xattrs (StressNode *node, StressHostFile *file) override {
825894 return StressInterImpl::build_gen_xattrs (node, file);
826895 }
@@ -837,6 +906,9 @@ class StressCase009: public StressBase, public StressInterImpl {
837906 bool build_dir_own (StressNode *node, struct in_mem_meta *meta) override {
838907 return StressInterImpl::build_dir_own (node, meta);
839908 }
909+ bool build_dir_mtime (StressNode *node, struct in_mem_meta *meta) override {
910+ return StressInterImpl::build_dir_mtime (node, meta);
911+ }
840912 bool build_dir_xattrs (StressNode *node, const char *path, photon::fs::IFileSystem *host_fs) override {
841913 return StressInterImpl::build_dir_xattrs (node, path, host_fs);
842914 }
0 commit comments